在安装vue-cli3脚手架时报如下错误,
在这里插入图片描述
具体错误信息如下:

E:\1论文代码>vue create vue3-li
?  Your connection to the default npm registry seems to be slow.
   Use https://registry.npm.taobao.org for faster installation? Yes


Vue CLI v3.9.1
? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Router, Vuex
? Use history mode for router? (Requires proper server setup for index fallback in production) No
? Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? In package.json
? Save this as a preset for future projects? No


Vue CLI v3.9.1
✨  Creating project in E:\1论文代码\vue3-li.
?  Initializing git repository...
⚙  Installing CLI plugins. This might take a while...

npm ERR! path E:\1论文代码\vue3-li\node_modules\.staging\terser-481ed825\dist\bundle.js.map
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'E:\1论文代码\vue3-li\node_modules\.staging\terser-481ed825\dist\bundle.js.map'
npm ERR!  [OperationalError: EPERM: operation not permitted, unlink 'E:\1论文代码\vue3-li\node_modules\.staging\terser-481ed825\dist\bundle.js.map'] {
npm ERR!   cause: [Error: EPERM: operation not permitted, unlink 'E:\1论文代码\vue3-li\node_modules\.staging\terser-481ed825\dist\bundle.js.map'] {
npm ERR!     errno: -4048,
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'unlink',
npm ERR!     path: 'E:\\1论文代码\\vue3-li\\node_modules\\.staging\\terser-481ed825\\dist\\bundle.js.map'
npm ERR!   },
npm ERR!   stack: 'Error: EPERM: operation not permitted, unlink ' +
npm ERR!     "'E:\\1论文代码\\vue3-li\\node_modules\\.staging\\terser-481ed825\\dist\\bundle.js.map'",
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path: 'E:\\1论文代码\\vue3-li\\node_modules\\.staging\\terser-481ed825\\dist\\bundle.js.map',
npm ERR!   parent: 'vue3-li'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
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).
终止批处理操作吗(Y/N)? y

经查找,与npm-cache缓存有关,个人理解应该是所要加载的依赖包有些存在缓存中,但不够完整,而npm在下载依赖包时发现本地有该依赖包就直接拿来用,导致报错,因此可以先通过执行npm cache verify验证本地缓存中的依赖是否完整,然后再搭建脚手架,如下执行后不再报错:

E:\1论文代码>npm cache verify
Cache verified and compressed (~\AppData\Roaming\npm-cache\_cacache):
Content verified: 4381 (104147387 bytes)
Content garbage-collected: 9 (898944 bytes)
Index entries: 6960
Finished in 107.994s

E:\1论文代码>vue create vue3-li


Vue CLI v3.9.1
? Target directory E:\1论文代码\vue3-li already exists. Pick an action: Overwrite

Removing E:\1论文代码\vue3-li...


Vue CLI v3.9.1
? Please pick a preset: Manually select features
? Check the features needed for your project: Babel, Router
? Use history mode for router? (Requires proper server setup for index fallback in production) No
? Where do you prefer placing config for Babel, PostCSS, ESLint, etc.? In package.json
? Save this as a preset for future projects? No


Vue CLI v3.9.1
✨  Creating project in E:\1论文代码\vue3-li.
?  Initializing git repository...
⚙  Installing CLI plugins. This might take a while...


> core-js@2.6.9 postinstall E:\1论文代码\vue3-li\node_modules\core-js
> node scripts/postinstall || echo "ignore"

added 1072 packages from 889 contributors and audited 18238 packages in 83.754s
found 0 vulnerabilities

?  Invoking generators...
?  Installing additional dependencies...

added 4 packages from 1 contributor and audited 18244 packages in 17.903s
found 0 vulnerabilities

⚓  Running completion hooks...

?  Generating README.md...

?  Successfully created project vue3-li.
?  Get started with the following commands:

 $ cd vue3-li
 $ npm run serve
Logo

前往低代码交流专区

更多推荐