当npm开始时,react-native中给出的错误

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

我使用的是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.

请帮助纠正问题

node.js react-native npm
6个回答
1
投票

我认为你在MAC上运行你的代码。如果是,请尝试运行以下命令:

sudo chown -R username:groupname directory

其中“username”是您当前的用户名,“groupname”是您的主要组,“directory”是您的项目目录路径。 然后删除node_modules文件夹并尝试以下命令:

npm install
npm start

1
投票

试试跑步:

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”


0
投票

如果您尚未安装webpack-dev-server,请通过发出以下命令来执行此操作

npm install -g webpack webpack-dev-server

如果您已经完成它,请尝试删除node_modules目录并运行新的npm install,然后再执行react-native-scripts start命令。

希望这可以帮助。


0
投票

您可能没有必要的权限,因此您会看到:

sh: 1: react-native-scripts: Permission denied

尝试启动它:

sudo react-native-scripts start

0
投票

我遇到了同样的问题,令人惊讶的是它在Windows中工作正常但在Linux中失败却给出了同样的错误。请按照以下步骤解决此问题。

你需要更改项目文件夹中的package.json文件,如下所示,而不是"start": "react-scripts start"的默认值

“scripts”:{“start”:“node ./node_modules/react-scripts/bin/react-scripts.js start”}


0
投票

我遇到了这个问题。它在执行sudo chmod -R 755后运行。

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