问题
:
在cmd中修改了npm缓存文件及全局模块文件路径后,通过获取vue信息出错。
C:UsersSueMagic>npm info vue
npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path b:nodejsnode_cache_cacache
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'b:nodejsnode_cache_cacache'
npm ERR! [Error: EPERM: operation not permitted, mkdir 'b:nodejsnode_cache_cacache'] {
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'mkdir',
npm ERR! path: 'b:\nodejs\node_cache\_cacache'
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.
npm ERR! Log files were not written due to an error writing to the directory: b:nodejsnode_cache_logs
npm ERR! You can rerun the command with `--loglevel=verbose` to see the logs in your terminal
C:UsersSueMagic>
C:UsersSueMagic>npm config ls
; "builtin" config from B:nodejsnode_modulesnpmnpmrc
; prefix = "C:\Users\SueMagic\AppData\Roaming\npm" ; overridden by user
; "user" config from C:UsersSueMagic.npmrc
cache = "b:\nodejs\node_cache"
prefix = "b:\nodejs\node_global"
registry = "https://registry.npmmirror.com/"
; node bin location = B:nodejsnode.exe
; node version = v18.16.0
; npm local prefix = C:UsersSueMagic
; npm version = 9.5.1
; cwd = C:UsersSueMagic
; HOME = C:UsersSueMagic
; Run `npm config ls -l` to show all defaults.
C:UsersSueMagic>
原因
:
修改后的路径依旧已经更改,但是应该要用管理员权限打开cmd;
解决
:
打开CMD应该用管理员权限打开来修改nodejs的缓存文件及全局文件的路径,并配置好其环境变量;
C:WINDOWSsystem32>npm config set cache "b:nodejsnode_cache"
C:WINDOWSsystem32>npm config set prefix "b:nodejsnode_global"
C:WINDOWSsystem32>npm config get prefix
b:nodejsnode_global
C:WINDOWSsystem32>npm config get cache
b:nodejsnode_cache
C:WINDOWSsystem32>npm config ls
; "builtin" config from B:nodejsnode_modulesnpmnpmrc
; prefix = "C:\Users\SueMagic\AppData\Roaming\npm" ; overridden by user
; "user" config from C:UsersSueMagic.npmrc
cache = "b:\nodejs\node_cache"
prefix = "b:\nodejs\node_global"
registry = "https://registry.npmmirror.com/"
; node bin location = B:nodejsnode.exe
; node version = v18.16.0
; npm local prefix = C:WINDOWSsystem32
; npm version = 9.5.1
; cwd = C:WINDOWSsystem32
; HOME = C:UsersSueMagic
; Run `npm config ls -l` to show all defaults.
配置PATH系统环境变量
在自己电脑上找到此电脑右键->属性->高级系统设置 ->环境变量
①在系统变量中点击新建,设置变量名NODE_PATH,变量值为B:nodejsnode_globalnode_modules(即是你设置的prefix的路径下的node_modules)
②在系统变量中点击新建,设置变量名NODE_HOME,变量值为B:nodejsnode_globalnode_global(即是你设置的prefix的路径下的node_modules)
点击确定。
在Path中加入刚刚新建的两个变量:
%NODE_HOME%
%NODE_PATH%
更改后:
C:WINDOWSsystem32>npm config set cache "b:nodejsnode_cache"
C:WINDOWSsystem32>npm config set prefix "b:nodejsnode_global"
C:WINDOWSsystem32>npm config get prefix
b:nodejsnode_global
C:WINDOWSsystem32>npm config get cache
b:nodejsnode_cache
C:WINDOWSsystem32>npm config ls
; "builtin" config from B:nodejsnode_modulesnpmnpmrc
; prefix = "C:\Users\SueMagic\AppData\Roaming\npm" ; overridden by user
; "user" config from C:UsersSueMagic.npmrc
cache = "b:\nodejs\node_cache"
prefix = "b:\nodejs\node_global"
registry = "https://registry.npmmirror.com/"
; node bin location = B:nodejsnode.exe
; node version = v18.16.0
; npm local prefix = C:WINDOWSsystem32
; npm version = 9.5.1
; cwd = C:WINDOWSsystem32
; HOME = C:UsersSueMagic
; Run `npm config ls -l` to show all defaults.
C:WINDOWSsystem32>npm info vue
vue@3.3.4 | MIT | deps: 5 | versions: 445
The progressive JavaScript framework for building modern web UI.
https://github.com/vuejs/core/tree/main/packages/vue#readme
keywords: vue
dist
.tarball: https://registry.npmmirror.com/vue/-/vue-3.3.4.tgz
.shasum: 8ed945d3873667df1d0fcf3b2463ada028f88bd6
.integrity: sha512-VTyEYn3yvIeY1Py0WaYGZsXnz3y5UnGi62GjVEqvEGPl6nxbOrCXbVOTQWBEJUqAyTUk2uJ5JLVnYJ6ZzGbrSw==
.unpackedSize: 2.0 MB
dependencies:
@vue/compiler-dom: 3.3.4 @vue/runtime-dom: 3.3.4 @vue/shared: 3.3.4
@vue/compiler-sfc: 3.3.4 @vue/server-renderer: 3.3.4
maintainers:
- posva <posva13@gmail.com>
- yyx990803 <yyx990803@gmail.com>
dist-tags:
alpha: 3.3.0-alpha.13 latest: 3.3.4 v2-alpha: 2.7.0-alpha.12
beta: 3.3.0-beta.5 legacy: 2.6.14 v2-beta: 2.7.0-beta.8
csp: 1.0.28-csp next: 3.2.36 v2-latest: 2.7.14
published a week ago by yyx990803 <yyx990803@gmail.com>
npm notice
npm notice New minor version of npm available! 9.5.1 -> 9.6.7
npm notice Changelog: https://github.com/npm/cli/releases/tag/v9.6.7
npm notice Run npm install -g npm@9.6.7 to update!
npm notice
C:WINDOWSsystem32>
原文地址:https://blog.csdn.net/SueMagic/article/details/130979556
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:http://www.7code.cn/show_48090.html
如若内容造成侵权/违法违规/事实不符,请联系代码007邮箱:suwngjj01@126.com进行投诉反馈,一经查实,立即删除!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。