且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在Swift中运行Shell命令

更新时间:2023-09-09 23:04:10

对此进行了更多研究.

nodejs安装程序使用/usr/local/bin,对于从Finder启动的应用程序,/usr/local/bin不包含在PATH中:

The nodejs installer uses /usr/local/bin, which is not included in the PATH for applications launched from Finder:

/usr/bin:/bin:/usr/sbin:/sbin

通过/etc/profile/etc/profile,该目录包含在为bash设置的PATH中. path_helper :

The directory is included in the PATH set for bash via /etc/profile & path_helper:

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

选项:

  • 只需编写/usr/local/bin/node而不是node.

通过environment属性调整NSTask使用的PATH.

使用 setenv PATH更改为system-也将影响NSTask.

Use setenv to change the PATH for system — will also affect NSTask.