可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I am stuck with this error no matter what directory I am in, and what I type after "npm" in cmd.exe. Here is the 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!
回答1:
I ran into the same problem while I was changing some npm settings. I did a mistake with one npm config set
command and this added a line referring to a non-existing directory to C:\Users\{User}\.npmrc
. After I deleted that line manually from .npmrc
, the problem was gone.
回答2:
EISDIR stands for "Error, Is Directory". This means that NPM is trying to do something to a file but it is a directory. In your case, NPM is trying to "read" a file which is a directory (Line: 4). Since the operation cannot be done the error is thrown.
Three things to make sure here.
- Make sure the file exists. If it does not, you need to create it. (If NPM depends on any specific information in the file, you will need to have that information there).
- Make sure it is in fact a file and not a directory.
- It has the right permissions. You can change the file to have all permissions with "sudo chmod 777 FILE_NAME". (Careful: You are giving Read, Write and Execute permissions to every one on that file)
回答3:
I had the same issue on Mac OS X (installed with homebrew), and the .npmrc is not the only place node stored config variables. There is a glocal npmrc config file in /usr/local/etc that you have to edit using this command:
sudo nano npmrc
Remove the ca=
line, or whatever the config setting was that broke your install, save that file, and try npm again, and you should see it working.
回答4:
In my case I was getting the "EISDIR: illegal operation on a directory, read" because in my .angular-cli.json file I wasn't providing a full path in "scripts:"
For example I had
"scripts": [
"../node_modules/hammerjs",
"../node_modules/moment"
],
In fact it should have been
"scripts": [
"../node_modules/hammerjs/hammer.min.js",
"../node_modules/moment/min/moment.min.js"
],
回答5:
Had the same problem today after i've upgraded my npm from version 6.4.1 to version 6.5.0. I fixed this by downloading the .pkg installer (recommended for most users) from node.js and runned it afterwards.
回答6:
Check to ensure you are running npm install from the proper directory.
(The package.json file could be one extra directory down, for example.)
回答7:
If your problem is associated with the React Native packager. Try resetting the cache with react-native start --reset-cache
.
回答8:
Doing a complete uninstall, including removing paths, etc and reinstalling has solved the problem, very strange problem though.
How to completely remove node.js from Windows
回答9:
I had this issue with gulp. The problem was that gulp added a dependency to my source file and I think npm tried to open it:
{
"name": "name",
"version": "2.0.0",
"description": "",
"main": "gulpfile.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"devDependencies": {
"appname": "file://gulp",
"gulp-concat": "^2.6.1",
"gulp-electron": "^0.1.3",
"gulp-shell": "^0.5.2",
"gulp-uglify": "^2.0.0",
"gulp-util": "^3.0.7",
"node-7z": "^0.4.0"
}
}
Make sure that there are no strange references in you package.json file.
回答10:
I had a similar problem while setting up boilerplate code. It was reading my bundle.js file as a directory. So as stated here. EISDIR mean its a directory and not a file. To fix the issue, I deleted the file and just recreated (it was originally created automatically).
If you cannot find the file (because its hidden), simply use the terminal to find and delete it.
回答11:
Had the same problem until I tried deleting the .git folder. It worked. I guess this type of problem can have different causes.
回答12:
I had the same issue. There was a linked folder in my directory which was causing the issue. i added that folder to ignore list and then it started working fine as expected.
回答13:
I know this isn't specifically asking about forever js.. but google lead me here so.. For me it was as simple as an ending slash.
I just changed:
forever start -a -l /dev/null/ /var/www/node/my_file.js
To:
forever start -a -l /dev/null /var/www/node/my_file.js
And the error disappeared
回答14:
For me fixing was add slash after directory name