【问题标题】:Having a problem with npm global install on MacOS 11.6.1 with M1 chip在带有 M1 芯片的 MacOS 11.6.1 上的 npm 全局安装出现问题
【发布时间】:2021-12-23 11:45:57
【问题描述】:

我正在尝试在终端中安装 npm,但我不断收到错误消息。

命令是

`npm install -g ts-node` 

这是错误的返回

npm ERR! code EACCES
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/ts-node/dist/bin-script-deprecated.js
npm ERR! dest /usr/local/bin/ts-script
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/ts- 
node/dist/bin-script-deprecated.js' -> '/usr/local/bin/ts-script'
npm ERR!  [Error: EACCES: permission denied, symlink '../lib/node_modules/ts- 
node/dist/bin-script-deprecated.js' -> '/usr/local/bin/ts-script'] {
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'symlink',
npm ERR!   path: '../lib/node_modules/ts-node/dist/bin-script-deprecated.js',
npm ERR!   dest: '/usr/local/bin/ts-script'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/aj/.npm/_logs/2021-11-10T21_41_24_060Z-debug.log

【问题讨论】:

    标签: node.js macos npm


    【解决方案1】:

    npm 有an entire web page specifically on how to resolve the issue of EACCES errors when installing packages globally。在那里找到所有细节。他们提出了许多可能的解决方案。我会推荐一个,特别是因为你可能在开发机器上遇到这个问题,是使用像nvm 这样的版本管理器,而不是你用来在你的机器上安装 Node.js 的任何包或任何东西。但请查看上述网页以了解其他选项。

    【讨论】:

    • 感谢您的链接!我现在要去那里。自从我直接从 node.js 站点下载后,我刚刚删除了所有节点文件。目前正在使用自制软件安装。将尝试使用 nvm 重新安装
    • 刚进去下载了。我放弃了 -g ,我绝对没有问题。关于为什么会这样的任何想法?
    • @ajdaviscodes 是的,如果您安装时不带 -g,那么它将作为依赖项安装在您的项目 node_modules 中,而不是全局系统目录中。在这种情况下,您很可能会遇到 EACCES 权限问题。
    猜你喜欢
    • 2021-09-29
    • 2021-09-01
    • 2022-07-05
    • 2022-10-20
    • 2021-11-29
    • 2022-09-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多