Homebrew 安装 node 后,npm报 env: node no such file or directory
程序员文章站
2022-07-16 09:21:16
...
在mac os 下通过homebrew 安装node后,npm会被链接为可直接运行的文件,但是其头部会包含如下代码,指定当前脚本运行上下文。
#!/usr/bin/env node
由于homebrew是非官方安装方法,因此node的安装位置不在 /usr/bin 中,如果碰到一些软件通过访问此路径来使用node就会报如题的错误。
解决方法是将node链接到 /usr/bin 中,对于最新版本的mac os,需要关闭 System Integrity Protection,否则即使sudo链接,也会报权限不够。
关闭SIP的方法,重启mac,屏幕黑掉后,立即按住 command+R不放,直到看到苹果logo,接着放开,系统会进入恢复模式,打开命令行,运行以下脚本之后重启,即关闭了SIP。
csrutil disable
上一篇: 【openWRT】编译问题/usr/bin/env: node: No such file or directory
下一篇: git clone到本地是报错:fatal:out of memory malloc failed tried to allocate完美解决,我就是这样解决的,希望对你有用
推荐阅读
-
Homebrew 安装 node 后,npm报 env: node no such file or directory
-
NPM项目运行出现安装node-sass报错Error: ENOENT: no such file or directory, scandir
-
cnpm安装报错 npm ERR! enoent ENOENT: no such file or directory, access 'D:\Develop\nodejs\node_global……
-
FAQ:NodeJS安装报错npm WARN saveError ENOENT: no such file or directory, open 'G:\Node\package.json'