關(guān)于npm install過程失敗的幾種處理方式
npm install過程失敗的處理
npm install過程失敗
第一種情況
// ?首先經(jīng)過npm install后,會(huì)生成node_modules,先清除它 rm -rf node_modules // ?如果項(xiàng)目中有package-lock.json文件 rm package-lock.json // 然后在繼續(xù)進(jìn)行包安裝 npm install (或者npm install --save ?后者會(huì)生成package-lock.json文件) // 如有提示需執(zhí)行(npm audit fix)(該處是有些包版本的問題, 需做一個(gè)版本替換) npm audit fix // 然后可開啟程序 node app.js / npm run dev (根據(jù)需要進(jìn)行選擇) // 若運(yùn)行過程提示缺少包,則繼續(xù)npm install ?包名
第二種情況
// 若是報(bào)錯(cuò)關(guān)于node@sass類的問題,也需先把之前安裝的包刪掉 rm -rf node_modules // 然后執(zhí)行 npm install --unsafe-perm
npm install 模塊失敗的原因之沒有創(chuàng)建package.json文件
以安裝 superagent 為例
npm i superagent
錯(cuò)誤日志如下
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /Users/zhangchi/node_modules/_minipass@2.9.0@minipass/node_modules/yallist
npm ERR! dest /Users/zhangchi/node_modules/_minipass@2.9.0@minipass/node_modules/.yallist-wfFlDPoD
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/Users/zhangchi/node_modules/_minipass@2.9.0@minipass/node_modules/yallist' -> '/Users/zhangchi/node_modules/_minipass@2.9.0@minipass/node_modules/.yallist-wfFlDPoD'
npm ERR! [Error: EACCES: permission denied, rename '/Users/zhangchi/node_modules/_minipass@2.9.0@minipass/node_modules/yallist' -> '/Users/zhangchi/node_modules/_minipass@2.9.0@minipass/node_modules/.yallist-wfFlDPoD'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/Users/zhangchi/node_modules/_minipass@2.9.0@minipass/node_modules/yallist',
npm ERR! dest: '/Users/zhangchi/node_modules/_minipass@2.9.0@minipass/node_modules/.yallist-wfFlDPoD'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
以安裝 superagent 為例
```shell npm i superagent
實(shí)際原因就是目錄缺少 package.json 文件,執(zhí)行
npm init --yes
總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Node.js使用MongoDB的ObjectId作為查詢條件的方法
這篇文章主要介紹了Node.js使用MongoDB的ObjectId作為查詢條件的方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-09-09
Windows環(huán)境下npm install 報(bào)錯(cuò): operation not permitted, rename的解決
這篇文章主要介紹了Windows環(huán)境下npm install 報(bào)錯(cuò): operation not permitted, rename的解決方法,文中對(duì)解決的方法介紹的很詳細(xì),有需要的朋友們可以參考借鑒。2016-09-09
使用pkg打包nodejs項(xiàng)目并解決本地文件讀取的問題
這篇文章主要介紹了使用pkg打包nodejs項(xiàng)目并解決本地文件讀取的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-10-10
windows系統(tǒng)下安裝npm(Node.js)方法教程
在Windows環(huán)境下進(jìn)行Node.js的安裝并不是一件復(fù)雜的事情,但是在安裝過程中需要注意一些細(xì)節(jié),下面這篇文章主要給大家介紹了關(guān)于windows系統(tǒng)下安裝npm(Node.js)的相關(guān)資料,需要的朋友可以參考下2023-12-12
搭建基于express框架運(yùn)行環(huán)境的方法步驟
Express提供了一個(gè)輕量級(jí)模塊,把Node.js的http模塊功能封裝在一個(gè)簡單易用的接口中,這篇文章主要介紹了搭建基于express框架運(yùn)行環(huán)境的方法步驟,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-11-11

