EPERM:不允许操作,mkdir 'C:\Program Files\nodejs\node_modules\.staging

ven*_*mar 8 node.js npm node-modules

我正在尝试在我的项目上运行 npm install 但它显示 EPERM: operation not allowed, mkdir 'C:\Program Files\nodejs\node_modules.staging

我没有 root 管理权限。我在我的系统中作为本地用户使用,我的系统是 Windows 10

节点 v10.16.3 npm v6.11.3

任何人都可以帮我解决这个问题。我请你们。

3235 error code EPERM
3236 error syscall mkdir
3237 error path C:\Program Files\nodejs\node_modules\.staging
3238 error errno -4048
3239 error Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_modules\.staging'
3239 error  { [Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_modules\.staging']
3239 error   cause:
3239 error    { Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_modules\.staging'
3239 error      errno: -4048,
3239 error      code: 'EPERM',
3239 error      syscall: 'mkdir',
3239 error      path: 'C:\\Program Files\\nodejs\\node_modules\\.staging' },
3239 error   stack:
3239 error    'Error: EPERM: operation not permitted, mkdir \'C:\\Program Files\\nodejs\\node_modules\\.staging\'',
3239 error   errno: -4048,
3239 error   code: 'EPERM',
3239 error   syscall: 'mkdir',
3239 error   path: 'C:\\Program Files\\nodejs\\node_modules\\.staging',
3239 error   parent: 'nodemon' }
3240 error The operation was rejected by your operating system.
3240 error It's possible that the file was already in use (by a text editor or antivirus),
3240 error or that you lack permissions to access it.
3240 error
3240 error If you believe this might be a permissions issue, please double-check the
3240 error permissions of the file and its containing directories, or try running
3240 error the command again as root/Administrator.
3241 verbose exit [ -4048, true ]
Run Code Online (Sandbox Code Playgroud)

小智 15

尝试清除缓存:

  • npm cache clean --force

或者

  1. npm uninstall npm -g
  2. npm install npm -g

或者

  • npm set prefix 'C:\Users\User\AppData\Roaming\npm'

最后一个对我有用

  • 转义斜杠并使用双引号 `npm set prefix "%USERPROFILE%\\AppData\\Roaming\\npm"` (5认同)

小智 7

运行这些命令:

npm uninstall -g create-react-app

npm install -g create-react-app
Run Code Online (Sandbox Code Playgroud)

这将升级你的 npx,然后运行

npx create-react-app my-app
Run Code Online (Sandbox Code Playgroud)