node.js - npm create-react-app 错误 : EACCES: permission denied. 该操作被您的操作系统拒绝

标签 node.js reactjs npm visual-studio-code terminal

我想在 vscode 中使用 react,但是当我尝试安装 node.js 时,它给了我错误。我的命令是

npm install -g create-react-app
npm ERR! code EACCES
npm ERR! syscall symlink
npm ERR! path ../lib/node_modules/create-react-app/index.js
npm ERR! dest /usr/local/bin/create-react-app
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, symlink '../lib/node_modules/create-react-app/index.js' -> '/usr/local/bin/create-react-app'
npm ERR!  [OperationalError: EACCES: permission denied, symlink '../lib/node_modules/create-react-app/index.js' -> '/usr/local/bin/create-react-app'] {
npm ERR!   cause: [Error: EACCES: permission denied, symlink '../lib/node_modules/create-react-app/index.js' -> '/usr/local/bin/create-react-app'] {
npm ERR!     errno: -13,
npm ERR!     code: 'EACCES',
npm ERR!     syscall: 'symlink',
npm ERR!     path: '../lib/node_modules/create-react-app/index.js',
npm ERR!     dest: '/usr/local/bin/create-react-app'
npm ERR!   },
npm ERR!   stack: "Error: EACCES: permission denied, symlink '../lib/node_modules/create-react-app/index.js' -> '/usr/local/bin/create-react-app'",
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'symlink',
npm ERR!   path: '../lib/node_modules/create-react-app/index.js',
npm ERR!   dest: '/usr/local/bin/create-react-app'
npm ERR! }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
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!     /Users/defneyazicioglu/.npm/_logs/2020-03-23T17_10_48_130Z-debug.log

我该如何解决

最佳答案

试试这些命令:

  1. $sudo -s
  2. $npm install -g create-react-app
  3. $退出
  4. $npx create-react-app 我的应用

关于node.js - npm create-react-app 错误 : EACCES: permission denied. 该操作被您的操作系统拒绝,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60818437/

相关文章:

node.js - 无法在 Heroku 上启动浏览器进程

npm - 使用 NPM 将 CSS 文件合并为单个文件

javascript - 如何将 git 分发忽略的文件发布到 Bower?

node.js - 如何处理nodejs fs readdir函数中的特殊字符

node.js - 在expressjs 4.x中将less文件编译为css

node.js - 将数据插入 MongoDB - 没有错误,没有插入

javascript - 使用 Nav 组件和 react-bootstrap 的 Accordion 侧边栏菜单

javascript - React 组件利用率

javascript - 在回调中设置 Prop 值

node.js - 在 VS2015 asp.net core 1.0 项目中使用 gulp 将文件从 node_modules 移动到 wwwroot