今天晚上在 Mac OS 下配置 Supervisor 时,其中一条命令是执行一个 「node」 命令,eg. node socket.js

但是启动的时候一直报 FATAL can't find command 'node' 错误,查询半天没有结果。

自己在站点执行 node socket.js node 命令的方法也可以调用,所以问题不在命令。

猜想可能和用户组有关,对比下

ll /usr/local/bin |grep node
lrwxr-xr-x  1 bigface  admin    39B  9  5  2017 grunt -> ../lib/node_modules/grunt-cli/bin/grunt
lrwxr-xr-x  1 bigface  admin    37B 12 24 18:39 jshint -> ../lib/node_modules/jshint/bin/jshint
lrwxr-xr-x  1 bigface  admin    31B 12 22 10:10 node -> ../Cellar/node/9.3.0_1/bin/node
lrwxr-xr-x  1 bigface  admin    46B 12 22 10:10 npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
lrwxr-xr-x  1 bigface  admin    46B 12 22 10:10 npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js
lrwxr-xr-x  1 bigface  admin    35B 10 28 22:08 vue -> ../lib/node_modules/vue-cli/bin/vue
lrwxr-xr-x  1 bigface  admin    40B 10 28 22:08 vue-init -> ../lib/node_modules/vue-cli/bin/vue-init
lrwxr-xr-x  1 bigface  admin    40B 10 28 22:08 vue-list -> ../lib/node_modules/vue-cli/bin/vue-list

ll /usr/bin |grep php
-rwxr-xr-x   1 root   wheel    11M 10  3 13:51 php

node 命令前增加了绝对路径,eg./usr/local/bin/node socket.js 执行成功。