node.js - "npm install"当 macOS Catalina 上存在 git 包依赖项时失败

标签 node.js macos npm npm-install macos-catalina

在具有 Git 依赖项的 Node.js 项目上运行“npm install”时,它在 macOS Catalina 上失败。

npm ERR! code EPERM
npm ERR! syscall spawn
npm ERR! errno EPERM
npm ERR! Error: spawn EPERM
npm ERR!     at ChildProcess.spawn (internal/child_process.js:394:11)
npm ERR!     at Object.spawn (child_process.js:540:9)
npm ERR!     at /Users/user/.node/lib/node_modules/npm/node_modules/pacote/lib/util/git.js:216:24
npm ERR!     at /Users/user/.node/lib/node_modules/npm/node_modules/promise-retry/index.js:29:24
npm ERR!  OperationalError: spawn EPERM
npm ERR!     at ChildProcess.spawn (internal/child_process.js:394:11)
npm ERR!     at Object.spawn (child_process.js:540:9)
npm ERR!     at /Users/user/.node/lib/node_modules/npm/node_modules/pacote/lib/util/git.js:216:24
npm ERR!     at /Users/user/.node/lib/node_modules/npm/node_modules/promise-retry/index.js:29:24 {
npm ERR!   cause: Error: spawn EPERM
npm ERR!       at ChildProcess.spawn (internal/child_process.js:394:11)
npm ERR!       at Object.spawn (child_process.js:540:9)
npm ERR!       at /Users/user/.node/lib/node_modules/npm/node_modules/pacote/lib/util/git.js:216:24
npm ERR!       at /Users/user/.node/lib/node_modules/npm/node_modules/promise-retry/index.js:29:24 {
npm ERR!     errno: 'EPERM',
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'spawn'
npm ERR!   },
npm ERR!   isOperational: true,
npm ERR!   stack: 'Error: spawn EPERM\n' +
npm ERR!     '    at ChildProcess.spawn (internal/child_process.js:394:11)\n' +
npm ERR!     '    at Object.spawn (child_process.js:540:9)\n' +
npm ERR!     '    at /Users/user/.node/lib/node_modules/npm/node_modules/pacote/lib/util/git.js:216:24\n' +
npm ERR!     '    at /Users/user/.node/lib/node_modules/npm/node_modules/promise-retry/index.js:29:24',
npm ERR!   errno: 'EPERM',
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'spawn'
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/user/.npm/_logs/2019-10-30T08_40_20_156Z-debug.log

似乎通过 npm 脚本执行 Git 被操作系统阻止了。它适用于以前的 macOS 版本。如果我运行“sudo npm install”,它也适用于 macOS Catalina。

最佳答案

发生这种情况是因为当前用户的默认组与源目录的组不同(即使用户具有源目录的访问权限)。我的默认组是工作人员,但目录的组是管理员,当我将目录的组更改为工作人员“npm ci/install”时工作正常。 找到解决方案表格here .

关于node.js - "npm install"当 macOS Catalina 上存在 git 包依赖项时失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58623570/

相关文章:

node.js - 如何在NeptuneDB中进行分页以实现高性能

ios - 如何通过mac终端获取连接的iPhone IP地址

node.js - zsh : command not found: npm

node.js - elasticsearch:错误:无法解析/序列化正文

javascript - 向对象 Mongoose 方式添加字段

javascript - 需要一个使用dust.js或handlebars.js以及express3.x和node的两页示例

node.js - Winston日志模块中,为什么发送不同级别的日志不起作用

macos - Mac OSX Snow Leopard 上的 ImageMagick。有什么办法让它编译并运行吗?

python - 安装 Pandas 的问题 : "command ' llvm-gcc-4. 2' failed with exit status 1"

javascript - Webpack 在使用 npm 链接时给出 eslint 错误