getting “Error: EINVAL: invalid argument, read” for “npm install --save-dev eslint --verbose”

时光怂恿深爱的人放手 提交于 2019-12-11 07:57:38

问题


Any ideas/assistance here re how to get "npm install --save-dev eslint --verbose" working. I keep getting:

Error: EINVAL: invalid argument, read

I've setup up a new react-native project:

react-native init gcLists

E:\gcLists>npm -v
5.5.1
E:\gcLists>yarn -v
1.2.1
E:\gcLists>react-native -v
react-native-cli: 2.0.1
react-native: 0.49.5

npm install --save-dev eslint --verbose

Last part of the log:

npm http fetch GET 304 https://registry.npmjs.org/slice-ansi 104ms (from cache)
npm verb correctMkdir D:\Users\greg\AppData\Roaming\npm-cache\_locks correctMkdir not in flight; initializing
npm verb lock using D:\Users\greg\AppData\Roaming\npm-cache\_locks\staging-255cd84f0d76b150.lock for E:\gcLists\node_modules\.staging
npm info lifecycle semver@5.4.1~preuninstall: semver@5.4.1
npm info lifecycle semver@5.4.1~uninstall: semver@5.4.1
npm verb unbuild rmStuff semver@5.4.1 from E:\gcLists\node_modules
npm verb unlock done using D:\Users\greg\AppData\Roaming\npm-cache\_locks\staging-255cd84f0d76b150.lock for E:\gcLists\node_modules\.staging
npm verb stack Error: EINVAL: invalid argument, read
npm verb stack     at D:\Users\greg\AppData\Roaming\npm\node_modules\npm\lib\utils\gently-rm.js:275:7
npm verb stack     at D:\Users\greg\AppData\Roaming\npm\node_modules\npm\node_modules\iferr\index.js:13:50
npm verb stack     at D:\Users\greg\AppData\Roaming\npm\node_modules\npm\node_modules\graceful-fs\polyfills.js:287:18
npm verb stack     at FSReqWrap.oncomplete (fs.js:154:5)
npm verb cwd E:\gcLists
npm verb Windows_NT 6.1.7601
npm verb argv "C:\\Program Files\\nodejs\\node.exe" "D:\\Users\\greg\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save-dev" "eslint" "--verbose"
npm verb node v8.7.0
npm verb npm  v5.5.1
npm ERR! code EINVAL
npm ERR! EINVAL: invalid argument, read
npm verb exit [ 1, true ]

npm ERR! A complete log of this run can be found in:
npm ERR!     D:\Users\greg\AppData\Roaming\npm-cache\_logs\2017-11-03T02_38_08_842Z-debug.log

Notes:

  • On Windows 7

UPDATE: * Results of npm install --save-dev eslint --verbose may be found here.


回答1:


Sometimes some packages have issues with npm. This could be base on combination of OS/package version/node version/npm version compatibility issue.

In such cases best thing is to do is try and use some other package manager. Try this with yarn

yarn add eslint



回答2:


Since you are using drive letter E:, you might be on a portable drive. I had the same problem using an USB-Stick formatted on FAT32. I solved it reformatting to NTFS.




回答3:


What helped me was to also delete my package-lock.json file.

rm -rf node_modules package-lock.json
npm i



回答4:


Try cleaning the npm cache:

npm cache clean

Then try again.




回答5:


I was getting the error when I did npm update so i deleted some npm outdated node_modules and ran npm update again and it worked.

yarn upgrade also fixed the thing.




回答6:


Same problem happened to me and what i did was deleting the whole node_modules folder and run npm install again. It fixed the error. The reason was in the initial npm install it was closed in the middle by me which crashed some files.



来源:https://stackoverflow.com/questions/47087759/getting-error-einval-invalid-argument-read-for-npm-install-save-dev-esli

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!