javascript - create-react-app newproject 命令行对我不起作用
问题描述
由于某种原因,当我输入 create-react-app newproject 命令时,我以“找不到命令”告终。它一直给我这个错误:
npm WARN checkPermissions Missing write access to /Users/kennyquach/.npm-global/lib/node_modules/create-react-app
npm ERR! path /Users/kennyquach/.npm-global/lib/node_modules/create-react-app
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/Users/kennyquach/.npm-global/lib/node_modules/create-react-app'
npm ERR! { Error: EACCES: permission denied, access '/Users/kennyquach/.npm-global/lib/node_modules/create-react-app'
npm ERR! stack: 'Error: EACCES: permission denied, access \'/Users/kennyquach/.npm-global/lib/node_modules/create-react-app\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/Users/kennyquach/.npm-global/lib/node_modules/create-react-app' }
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/kennyquach/.npm/_logs/2018-11-28T17_50_32_739Z-debug.log
任何帮助表示赞赏!谢谢!
解决方案
您很可能使用 Mac OS 作为操作系统。这是 MacOS 中全局安装包的普遍问题,由内置节点应用程序的文件权限引起。实际上你可以通过create-react-app
以root身份执行来克服这个问题,但我不建议这样做,它没有用而且有风险。
所以你有2个选择。(第一个难做,第二个火爆)
1-) 从您的系统中完全删除 Node 并使用Brew安装它。您可以使用该包管理器轻松更新节点并安装任何其他流行的开发工具(例如:mongodb、mysql、pgsql、rabbitmq 等)。您可以从此处获取 brew:https ://brew.sh并使用该代码安装节点:brew install node
2-) 您可以轻松地授予对您的文件夹和文件的读取、写入、执行访问权限。您可以这样做:sudo chmod -R 777 /Users/kennyquach/.npm-global/
当 sudo 询问您的密码时,请使用您的管理员密码。
推荐阅读
- plot - 在散景中使用数据线宽
- arrays - 从 BiQuery 数据 JSON 中的数组中提取索引值
- google-apps-script - 如何在 Data Studio 中嵌入使用 Apps 脚本创建的 Web 应用程序?
- python - 类对象不打印
- javascript - 如何阻止我的毫秒数?
- angular - 如何在 Angular 2 Karma Jasmine 中使用 httpheaders 为 http 编写单元测试?
- reactjs - 为什么“npm run dev”会锁定 next.js 中的“本地主机就绪”?
- python - AttributeError:“FactorAnalyzer”对象没有“分析”属性
- joomla - 如何将不同的 Joomla 模板样式分配给一个包含文章的类别?
- azure-keyvault - 是否可以将 azure databricks 机密范围连接到其他资源组上的密钥库