欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

關(guān)于npm install過程失敗的幾種處理方式

 更新時間:2023年06月28日 09:11:17   作者:賜我一顆平常心  
這篇文章主要介紹了關(guān)于npm install過程失敗的幾種處理方式,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教

npm install過程失敗的處理

npm install過程失敗

第一種情況

// ?首先經(jīng)過npm install后,會生成node_modules,先清除它
rm -rf node_modules
// ?如果項目中有package-lock.json文件
rm package-lock.json
// 然后在繼續(xù)進(jìn)行包安裝
npm install (或者npm install --save ?后者會生成package-lock.json文件)
// 如有提示需執(zhí)行(npm audit fix)(該處是有些包版本的問題, 需做一個版本替換)
npm audit fix
// 然后可開啟程序
node app.js / npm run dev (根據(jù)需要進(jìn)行選擇)
// 若運行過程提示缺少包,則繼續(xù)npm install ?包名

第二種情況

// 若是報錯關(guān)于node@sass類的問題,也需先把之前安裝的包刪掉
rm -rf node_modules
// 然后執(zhí)行
npm install --unsafe-perm

npm install 模塊失敗的原因之沒有創(chuàng)建package.json文件

以安裝 superagent 為例

npm i superagent

錯誤日志如下

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

實際原因就是目錄缺少 package.json 文件,執(zhí)行

npm init --yes

總結(jié)

以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論