create-react-app newproject命令行不适用于我

问题描述 投票:1回答:2

由于某种原因,当我键入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

任何帮助表示赞赏! 谢谢!

javascript node.js reactjs react-native
2个回答
1
投票

该错误清楚地表明您没有对/Users/kennyquach/.npm-global/lib/node_modules/create-react-app写权限

尝试将所有.npm-global文件夹的访问权限更改为777,然后尝试一下。


1
投票

您很有可能使用Mac OS作为操作系统。 这是MacOS中全局安装的软件包的一个普遍问题,它是由内置节点应用程序的文件权限引起的。 实际上,您可以通过以root身份执行create-react-app来解决此问题,但我不建议这样做,它没有用,而且存在风险。

因此,您有2个选择。 (第一个是很难做的,第二个是快速燃烧的)

1-)从系统中完全删除Node并使用Brew安装它。 您可以使用该程序包管理器轻松更新节点,并安装其他任何流行的开发人员工具(例如:mongodb,mysql,pgsql,rabbitmq等)。 您可以从以下位置获取brew: https : //brew.sh并使用以下代码brew install nodebrew install node

2-)您可以轻松地授予对文件夹和文件的读取,写入,执行访问权限。 您可以这样操作: sudo chmod -R 777 /Users/kennyquach/.npm-global/当sudo询问您的密码时,请使用管理员密码。

© www.soinside.com 2019 - 2024. All rights reserved.