【问题标题】:npm create-react-app Error: EACCES: permission denied. The operation was rejected by your operating systemnpm create-react-app 错误:EACCES:权限被拒绝。该操作被您的操作系统拒绝
【发布时间】:2020-07-04 04:53:57
【问题描述】:

我想在 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

我该如何解决这个问题

【问题讨论】:

  • 只需从命令中删除-g。你不需要全局安装create-react-app
  • 错误是因为你没有权限。
  • 使用 sudo npm install -g create-react-app
  • 这基本上是因为您的用户无权全局安装 npm 模块。我知道有两个修复。 1.使用sudo安装模块。像sudo npm install -g create-react-app 或 2. 您可以在没有 root 访问权限的情况下安装 node js。从这里找到更多信息:medium.com/@nadun1indunil/do-not-sudo-npm-why-5b9adff8caa2.

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


【解决方案1】:

试试这些命令:

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

【讨论】:

    猜你喜欢
    • 2020-08-18
    • 1970-01-01
    • 2023-02-14
    • 2019-10-28
    • 2021-07-22
    • 2018-03-01
    • 2016-11-14
    • 2017-12-29
    • 2021-07-28
    相关资源
    最近更新 更多