简体   繁体   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'

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 startreact-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 进程。

error错误

As mentioned here正如这里提到的

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.

相关问题 React-Native:将组件导入App.js时出错 - React-Native : error while import component to App.js 创建反应本机初始化命令时出错 - Error during creating react native init command npx react-native init 错误在 appdata 文件夹中不包含 package.json 文件 - npx react-native init error does not contain a package.json file in appdata folder 初始化本机项目时出现“错误监视文件的更改:EMFILE” - “Error watching file for changes: EMFILE” when init a react-native project react-native链接给出错误,没有这样的文件或目录info.plist - react-native link giving error no such file or directory info.plist 如何在 React-Native 应用程序中引发本机错误? - How to raise native error in React-Native app? 使用带有 http://localhost:3456/fileName/ 的 epubjs 时,本机 android 应用程序中出现空响应错误 - empty response error in react-native android app while using epubjs with http://localhost:3456/fileName/ 在 react-native 中创建 stackNavigator 后导航到页面时出错 - Error when navigating to a page after creating stackNavigator in react-native 运行 `react-native run-android` 时出错 - Getting error while running `react-native run-android` 尝试登录时反应本机,Firebase网络错误 - React-native, Firebase network error while trying to log in
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM