无论我在什么目录下,无论我在cmd.exe中键入“npm”后,我都被这个错误卡住了。下面是npm-debug.log:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js' ]
2 info using npm@2.14.12
3 info using node@v4.2.6
4 verbose stack Error: EISDIR: illegal operation on a directory, read
4 verbose stack     at Error (native)
5 verbose cwd C:\Users\me
6 error Windows_NT 6.1.7601
7 error argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js"
8 error node v4.2.6
9 error npm  v2.14.12
10 error code EISDIR
11 error errno -4068
12 error syscall read
13 error eisdir EISDIR: illegal operation on a directory, read
13 error eisdir This is most likely not a problem with npm itself
13 error eisdir and is related to npm not being able to find a package.json in
13 error eisdir a package you are trying to install.
14 verbose exit [ -4068, true ]

I have tried and uninstalling/reinstalling nodejs multiple times, I even deleted npm and npm-cache folders in C:\Users\me\AppData\Roaming. I'm not sure what went wrong to cause this. One second it was working fine, and now I can't get rid of this error. The explanation in the log does not make sense, as it gives this error in any directory. I should note that running a command prompt as administrator does not give this error. I'm pulling my hair out this Friday evening trying to get this fixed, any help would be greatly appreciated!


当前回答

检查确保你在正确的目录下运行npm install。

(包。Json文件可以是一个额外的目录下,例如。)

其他回答

我在Mac OS X上也遇到了同样的问题(安装了自制程序),而且.npmrc不是唯一存储配置变量的节点。在/usr/local/etc中有一个glocal npmrc配置文件,你必须使用这个命令编辑:

sudo nano npmrc

删除ca=行,或者任何破坏安装的配置设置,保存该文件,并再次尝试npm,你应该会看到它工作了。

对我来说,修复是在目录名称后添加斜杠

在我的例子中,C:\Users\{user}\AppData\local\npm文件被隐藏,所以我无法找到并删除故障目录。我花了几天时间才意识到这一点!

所以,仔细检查,取消隐藏任何文件夹,这样你就不会错过它们!如果你不知道怎么做,这里有一个链接。

对我来说,这是因为我走错了路;它应该是一个文件的路径,但我错误地使用了一个目录的路径:

改变:

path.resolve(__dirname, '../');

到这个:

path.resolve(__dirname, '../.env')

这些奇怪的错误最近发生在我的OSX机器上。

我可以用快速而肮脏的方式来帮助自己:

sudo chmod -R 777 /usr/local/lib/node_modules/

似乎有什么东西打乱了所有全局节点模块的访问权限。