繁体   English   中英

使用 react-native init 创建应用程序时出错<AppName> :错误:[Errno 2] 没有这样的文件或目录:“添加”

[英]Error while creating a app with react-native init <AppName>: ERROR: [Errno 2] No such file or directory: 'add'

我正在尝试使用“react-native init”创建一个 react-native 应用程序,但它抛出以下错误。 我之前创建过应用程序,但是当我尝试创建新应用程序时它突然开始抛出此错误

错误:[Errno 2] 没有这样的文件或目录:“添加”

我试着做npm startreact-native start 并删除了node_modules并重新安装了它。

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:未处理的承诺拒绝。

这个错误要么是因为在没有 catch 块的情况下抛出了异步函数,要么是因为拒绝了一个没有用 .catch() 处理过的承诺。 (rejection id: 2) (node:9851) [DEP0018] DeprecationWarning:不推荐使用未处理的承诺拒绝。 将来,未处理的承诺拒绝将使用非零退出代码终止 Node.js 进程。

错误

正如这里提到的

首先,在使用sudo apt install yarn安装 yarn 之前运行sudo apt remove cmdtest

您需要按照网站https://yarnpkg.com/lang/en/docs/install/上的安装说明进行操作,并先添加一个 repo。 这将包括正确的纱线,如果发生冲突,则用于更正运行以下命令:

sudo apt-get -o Dpkg::Options::="--force-overwrite" install yarn 

这个(“node_modules/execa/index.js”)文件也有类似的错误。 我使用下面给出的 2 个命令解决了我的错误

npm uninstall -g react-native-cli
yarn global add @react-native-community/cli

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM