[英]Error while creating a app with react-native init <AppName>: ERROR: [Errno 2] No such file or directory: 'add'
I'm trying to create a react-native app using "react-native init" but its throwing the below error.我正在尝试使用“react-native init”创建一个 react-native 应用程序,但它抛出以下错误。 I have created apps before but it suddenly started to throw this error when i tried to create a new app
我之前创建过应用程序,但是当我尝试创建新应用程序时它突然开始抛出此错误
ERROR: [Errno 2] No such file or directory: 'add'
错误:[Errno 2] 没有这样的文件或目录:“添加”
I tried to do npm start
, react-native start
.我试着做
npm start
, react-native start
。 and deleted the node_modules
and re-installed it.并删除了
node_modules
并重新安装了它。
info Setting up new React Native app in /home/sagar/Desktop/rn- prac/justTesting info Adding required dependencies ERROR: [Errno 2] No such file or directory: 'add' (node:9851) UnhandledPromiseRejectionWarning: Error: Command failed: yarn add react@16.8.6 at makeError (/home/sagar/Desktop/rn- prac/justTesting/node_modules/execa/index.js:174:9) at Promise.all.then.arr (/home/sagar/Desktop/rn- prac/justTesting/node_modules/execa/index.js:278:16) at process._tickCallback (internal/process/next_tick.js:68:7) (node:9851) UnhandledPromiseRejectionWarning: Unhandled promise rejection.
info 在 /home/sagar/Desktop/rn- prac/justTesting info 中设置新的 React Native 应用程序添加所需的依赖项错误:[Errno 2] 没有这样的文件或目录:'add'(节点:9851)UnhandledPromiseRejectionWarning:错误:命令失败: yarn add react@16.8.6 at makeError (/home/sagar/Desktop/rn- prac/justTesting/node_modules/execa/index.js:174:9) at Promise.all.then.arr (/home/sagar/ Desktop/rn- prac/justTesting/node_modules/execa/index.js:278:16) at process._tickCallback (internal/process/next_tick.js:68:7) (node:9851) UnhandledPromiseRejectionWarning:未处理的承诺拒绝。
This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch().
这个错误要么是因为在没有 catch 块的情况下抛出了异步函数,要么是因为拒绝了一个没有用 .catch() 处理过的承诺。 (rejection id: 2) (node:9851) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated.
(rejection id: 2) (node:9851) [DEP0018] DeprecationWarning:不推荐使用未处理的承诺拒绝。 In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
将来,未处理的承诺拒绝将使用非零退出代码终止 Node.js 进程。
First, run sudo apt remove cmdtest
before installing yarn with sudo apt install yarn
or首先,在使用
sudo apt install yarn
安装 yarn 之前运行sudo apt remove cmdtest
或
You need to follow the installation instructions on the website https://yarnpkg.com/lang/en/docs/install/ and add a repo first.您需要按照网站https://yarnpkg.com/lang/en/docs/install/上的安装说明进行操作,并先添加一个 repo。 This will then include the correct yarn, and if a conflict occurs then for correcting run following command:
这将包括正确的纱线,如果发生冲突,则用于更正运行以下命令:
sudo apt-get -o Dpkg::Options::="--force-overwrite" install yarn
I too got a similar error with this("node_modules/execa/index.js") file.这个(“node_modules/execa/index.js”)文件也有类似的错误。 I resolved my error using the 2 commands given below
我使用下面给出的 2 个命令解决了我的错误
npm uninstall -g react-native-cli
yarn global add @react-native-community/cli
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.