我正在尝试使用npm install express-generator -g
安装express-generator。但是我遇到了错误。
WARN tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/ejs-2de19af3/lib'026584d.lock for /usr/local/lib/node_modules/.staging
WARN tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/sorted-object-b497dff3/lib'
WARN tar EISDIR: blah blah many more lines like this
WARN tar EISDIR: illegal operation on a directory, open '/usr/local/lib/node_modules/.staging/mkdirp-f65a1b18/test'
npm ERR! path /usr/local/lib/node_modules/express-generator/node_modules/mkdirp/bin/cmd.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod '/usr/local/lib/node_modules/express-generator/node_modules/mkdirp/bin/cmd.js'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/xXc00lUs3rXx/.npm/_logs/2019-01-04T03_45_41_388Z-debug.log
我不确定EISDIR警告是关于什么的,但是对于ENOENT chmod错误,它正在尝试访问/usr/local/lib/node_modules/express-generator/
,但是没有这样的目录。
我在Mac上运行npm。我不确定如何解决此问题。
答案 0 :(得分:1)
尝试下一个命令:
1)sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
它将lib / node_modules,bin,share的所有者更改为您的macOS用户
2)npm install express-generator -g
第一步之后,当在global more中安装时,您无需使用'sudo'。
答案 1 :(得分:1)
我只是在同一条船上。您正在运行什么版本的NPM?根据{{3}}线程,NPM @ 6.5可能导致全局NPM安装失败。我在尝试降级到NPM@6.4.1时遇到了更多错误,最终卸载并重新安装了Node。我回到NPM@6.5,一切恢复正常。