npm踩坑问题实战记录白雪公主的故事完整版
⽬录
⼀、npm安装依赖失败问题
⼆、npmlockfile报错
三、npmERR!codeEPERM问题
四、npmERR!codeEEXIST(⽂件已存在,拒绝删除)
补充:通过npm命令来删除node_modules⽂件夹
总结
悲催的我基本上问题都遇到了。。。。。。
⼀、npm安装依赖失败问题
问题描述:
着的多音字
错误信息:unbuild: sill gentlyRm target.inParent = fal
后续会出现长时间停留
问题解决:删除整个node_modules,重新npm install
⼆、 npm lockfile报错
问题描述:
这个是因为版本问题导致的提⽰信息。
错误信息:
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, plea
npm WARN old lockfile
问题解决:
1. 忽略它。这只是⼀个警告,所发⽣的npm只是向package-lock.json⽂件添加信息。
2. npm在⽣产中降级到旧版本。考虑运⾏npm版本 6,npm i npm@6 -g 或者 npm -g install npm@6
3. 如果已经安装了⼀个新版本的npm,要保留较新版本,使⽤旧版本运⾏⼀个npm命令,可以使⽤npx来执⾏。使⽤该-p标
志来指定npm想要的版本。例如,即使安装了版本 7 ,运⾏npx -p npm@6 npm ci,也会使npm ci以npm版本 6运⾏。三、npm ERR! code EPERM问题
问题描述:
这是因为在git bash here,vs code等第三⽅,不以管理员⾝份运⾏造成的问题,就根本来说git bash here是windows dos命令封装过的。但是cmd 以管理员⾝份运⾏就需要定位到相应⽂件夹操作(需要
先进⼊相应盘,再进⼊相应⽂件,⽐较⿇烦),但是从第三⽅进⼊就可以直接在相应⽂件夹下操作,这样也⽐较⽅便。钱学森学院
错误信息:
$ npm install愤愤不平的意思
npm WARN tarball tarball data for typescript@3.0.3 (sha1-SFOz4nXs2qJ/eP2kbcJzp+t
/wcg=) ems to be corrupted. Trying one more time.
npm ERR! path E:\vue-typescript\node_modules\.staging\typescript-10ba8b53\lib\ty绝代双骄主题曲
pescriptServices.js
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'E:\vue-typescript\node_m odules\.staging\typescript-10ba8b53\lib\typescriptServices.js'
npm ERR! { Error: EPERM: operation not permitted, unlink 'E:\vue-typescript\nod
e_modules\.staging\typescript-10ba8b53\lib\typescriptServices.js'
npm ERR! cau:
npm ERR! { Error: EPERM: operation not permitted, unlink 'E:\vue-typescript\n
ode_modules\.staging\typescript-10ba8b53\lib\typescriptServices.js'
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'E:\\vue-typescript\\node_modules\\.staging\\typescript-10ba
8b53\\lib\\typescriptServices.js' },
npm ERR! stack: 'Error: EPERM: operation not permitted, unlink \'E:\\vue-types
cript\\node_modules\\.staging\\typescript-10ba8b53\\lib\\typescriptServices.js\'
',
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path: 'E:\\vue-typescript\\node_modules\\.staging\\typescript-10ba8b5
广州小洲村3\\lib\\typescriptServices.js',
npm ERR! parent: 'hello-world' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in u (by a text editor or ant
ivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!哀郢原文及翻译
npm ERR! If you believe this might be a permissions issue, plea double-check t
he
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended ).
问题解决:
需要删除.npmrc⽂件
强调:不是nodejs安装⽬录npm模块下的那个npmrc⽂件
⽽是在C:\Urs\{账户}\下的.npmrc⽂件
eg: 我的是C:\Urs\zhuzhu,下⾯有⼀个.npmrc
四、 npm ERR! code EEXIST(⽂件已存在,拒绝删除)问题描述:
npm ERR! code EEXIST
npm ERR! File exists: E:\software\node.js\node_global\vue
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with --force to overwrite files recklessly.
如提⽰,加⼊–force强制执⾏
问题解决:
1. 清理缓存
npm cache clean --force 或者清理node_cache缓存
2. 重新执⾏全局安装或者强制执⾏
npm install @vue/cli -g或者npm install -g @vue/cli --force
补充:通过npm命令来删除node_modules⽂件夹
⾸先通过npm安装删除⼯具
npm install rimraf -g
安装淘宝镜像后可以使⽤
cnpm install rimraf -g 命令⾏语句,速度会更快
在使⽤删除命令
rimraf node_modules
这个删除本项⽬的node_modules⽂件可以试试
删除整个项⽬的直接找到安装⽬录,把他移到回收站
总结
柑橘疮痂病到此这篇关于npm踩坑问题的⽂章就介绍到这了,更多相关npm踩坑问题内容请搜索以前的⽂章或继续浏览下⾯的相关⽂章希望⼤家以后多多⽀持!