`no such file or directory` While installing js beautify in npm

旧城冷巷雨未停 提交于 2019-12-10 12:49:31

问题


I get this error when i use npm -g install js-beautify

npm ERR! path /home/developer/software/nodejs/lib/node_modules/js-
beautify/js/bin/css-beautify.js
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod
npm ERR! enoent ENOENT: no such file or directory, chmod 
'/home/developer/software/nodejs/lib/node_modules/js-
beautify/js/bin/css-beautify.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!     /home/developer/.npm/_logs/2017-09-18T07_52_38_910Z-
debug.log

What can be done to solve this?

I am using node 8.5.0 an npm 5.3.0


回答1:


JS-Beautify 1.7.0 is broken.

Explicitly install the last good version:

npm -g install js-beautify@1.6.14

… or wait for a fixed version to be released.




回答2:


The fix for me was to add to package.json:

"devDependencies": { "js-beautify": "1.6.14",

and

"resolutions": { "js-beautify": "1.6.14" }

then delete the node_modules/ directory

and finaly reinstall all of the dependencies using npm install (for some reason yarn would fail - even after deleting yarn.lock)




回答3:


Add this to package.json for temporary fix

"dependencies": {
   "js-beautify": "1.6.14"
}


来源:https://stackoverflow.com/questions/46274964/no-such-file-or-directory-while-installing-js-beautify-in-npm

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