我使用的是Node - v10.6.0 Npm版本-4.6.1
当我尝试在我的项目文件夹下执行命令npm start时,它发出错误
[email protected] start / mnt / E / react_native / my_app
react-native-scripts启动
sh: 1: react-native-scripts: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! [email protected] start:
react-native-scripts start
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
请帮助纠正问题
我认为你在MAC上运行你的代码。如果是,请尝试运行以下命令:
sudo chown -R username:groupname directory
其中“username”是您当前的用户名,“groupname”是您的主要组,“directory”是您的项目目录路径。 然后删除node_modules文件夹并尝试以下命令:
npm install
npm start
试试跑步:
sudo sysctl -w fs.inotify.max_user_instances=1024
sudo sysctl -w fs.inotify.max_user_watches=12288
之前
npm start
这将暂时增加开发服务器能够监视更改的文件数。这个解决方案特定于Ubuntu / Linux - 相当于macOS的是“kern.maxfiles”和“kern.maxfilesperproc”
如果您尚未安装webpack-dev-server
,请通过发出以下命令来执行此操作
npm install -g webpack webpack-dev-server
如果您已经完成它,请尝试删除node_modules
目录并运行新的npm install
,然后再执行react-native-scripts start
命令。
希望这可以帮助。
您可能没有必要的权限,因此您会看到:
sh: 1: react-native-scripts: Permission denied
尝试启动它:
sudo react-native-scripts start
我遇到了同样的问题,令人惊讶的是它在Windows中工作正常但在Linux中失败却给出了同样的错误。请按照以下步骤解决此问题。
你需要更改项目文件夹中的package.json
文件,如下所示,而不是"start": "react-scripts start"
的默认值
“scripts”:{“start”:“
node ./node_modules/react-scripts/bin/react-scripts.js start
”}
我遇到了这个问题。它在执行sudo chmod -R 755后运行。