npm create-react-app错误:EACCES:权限被拒绝。该操作被您的操作系统拒绝

时间:2020-03-23 17:15:37

标签: 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 个答案:

答案 0 :(得分:0)

试试这些命令:

  1. $sudo -s
  2. $npm install -g create-react-app
  3. $退出
  4. $npx create-react-app my-app