reactjs - 安装错误:- npm install -g create-react-app

标签 reactjs npm

我正在 Udemy 上学习“Modern React with Redux Course”,有讲师要求先安装 NodeJs,然后安装“npm install -g create-react-app”,当我尝试运行此命令时,我得到了错误:-

npm install -g create-react-app
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }
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 (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/nitintushir/.npm/_logs/2019-09-20T15_22_12_437Z-debug.log

然后我在 stackoverflow 上回答了一些问题,有人建议运行这个命令:-

 npm cache clean --force

我得到了:

npm WARN using --force I sure hope you know what you are doing.

然后我运行

npm install -g create-react-app

再次命令,但仍然出现相同的错误,有什么解决方案/建议吗?

最佳答案

它看起来像是访问权限错误,您应该尝试以 root 身份运行安装,如下所示:

sudo npm install -g create-react-app

关于reactjs - 安装错误:- npm install -g create-react-app,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58031431/

相关文章:

reactjs - 如何使用 jest 和 React-testing-library 测试来自 sass 的样式?

reactjs - 'react-scripts start'命令到底是什么?

angular - 在 Material 工具提示中添加 href

javascript - 为开发构建 webpack 时出现语法错误

javascript - 为什么yarn在安装特定包时会提出以下请求?

javascript - React 中的 props.values 是什么?

javascript - npm run build 时显示错误

javascript - 在 React 中重用不同状态的 Fetch (Flux)

reactjs - Redux createStore<StoreState> 产生错误 : Expected 4 type arguments, 但得到 1

git - 将 github 组织或存储库标记为已弃用的标准方法?