关于#npm#的问题,如何解决?

报错内容


npm ERR! code EPERM
npm ERR! syscall mkdir
npm ERR! path C:\Users\57772\node_modules
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'C:\Users\57772\node_modules'
npm ERR!  [Error: EPERM: operation not permitted, mkdir 'C:\Users\57772\node_modules'] {
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: 'C:\\Users\\57772\\node_modules'
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! A complete log of this run can be found in:
npm ERR!     C:\Users\57772\AppData\Local\npm-cache\_logs\2023-06-12T02_39_50_396Z-debug-0.log

可是我的电脑没有搜到这个文件,path该配到哪个文件上面


npm ERR! path C:\Users\57772\node_modules
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, mkdir 'C:\Users\57772\node_modules'
npm ERR!  [Error: EPERM: operation not permitted, mkdir 'C:\Users\57772\node_modules'] {
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: 'C:\\Users\\57772\\node_modules'

你这个是环境配置的不对:
你可以参考一下这个:
引用来自:https://blog.csdn.net/qq_48485223/article/details/122709354
个人配置步骤:

安装Nodejs并新建React项目
1.下载Node.js 进行安装  https://nodejs.org/zh-cn/download
2.安装的目录要记住可以定义安装目录
3.在安装目录下新建两个文件夹 node_global 和 node_cache (列如:D:/NodeJs下这是我的安装目录)
4.文件夹建好后以管理员打开cmd输入以下命令:
npm config set prefix " D:\NodeJs\node_global"
npm config set cache " D:\NodeJs\node_cache"
5.配置环境变量: 电脑-属性-高级系统设置-将【用户变量】下的【Path】
修改为【D:\NodeJs\node_global】,之后点击确定。
6.在【系统变量】下新建【NODE_PATH】【D:\Nodejs\node_global\node_modules】
7.在【系统变量】下的【Path】新建添加node全局文件夹【D:\Nodejs\node_global】,之后点击确定。
8.安装npm install express -g ,更换淘宝映像nnpm config get registry
9.检查更换的配置 npm config get registry
10.全局全装淘宝的cnpm npm install -g cnpm --registry=https://registry.npm.taobao.org
11.C:\Windows\system32>cnpm -v 验证
12.进入D盘符:  返回上一级。 cd /  C:\cd /d D:
13.无法新建项目的时候需要安装脚手架:npm install -g create-react-app