npm install報錯 npm ERR! enoent ENOENT: no such file or directory


在npm之后出現如下錯誤:

$ npm install
npm WARN checkPermissions Missing write access to /Users/lucas/code/js/vue/train/vue-sample/node_modules/follow-redirects
npm ERR! path /Users/lucas/code/js/vue/train/vue-sample/node_modules/follow-redirects
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall access
npm ERR! enoent ENOENT: no such file or directory, access '/Users/lucas/code/js/vue/train/vue-sample/node_modules/follow-redirects'
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/lucas/.npm/_logs/2017-12-12T16_03_34_223Z-debug.log 

關於這個錯誤,網上有很多解決方法,但是都不適用在我這里。

解決方法

從錯誤來看, 是 /Users/lucas/code/js/vue/train/vue-sample/node_modules/follow-redirects 這個文件沒有權限或者沒有找到。
然后 ls 了一下這個文件, 得到如下結果:

$ ls -lt | grep follow-redirects
lrwxr-xr-x    1 lucas  staff     40 12 12 23:39 follow-redirects -> _follow-redirects@1.2.6@follow-redirects

可以看到這個是一個軟連接,鏈接到 _follow-redirects@1.2.6@follow-redirects 這個上面,很明顯,在這個目錄是沒有follow-redirects 這個東西的。
怎么辦呢? 很簡單 npm install follow-redirects 把這個東西安裝上去就好了。

安裝完成之后, 再 ls 一把

$ ls -lt | grep follow
drwxr-xr-x   10 lucas  staff    320 12 13 00:22 _follow-redirects@1.2.6@follow-redirects
lrwxr-xr-x    1 lucas  staff     40 12 12 23:39 follow-redirects -> _follow-redirects@1.2.6@follow-redirects

可以看到已經有了。

然后在 npm install 就沒有錯了。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM