Kia*_*jad 16 npm reactjs react-native
./gradlew cleanandroid 目录中的命令也有问题。我尝试过降级 npm 版本但没有帮助。有任何想法吗?
以下是我运行时得到的日志npx react-native run-android:
error Failed to load configuration of your project.
Error: Cannot find module '...\node_modules\json-parse-better-errors\index.js'. Please verify that the package.json has a valid "main" entry
at tryPackage (internal/modules/cjs/loader.js:320:19)
at Function.Module._findPath (internal/modules/cjs/loader.js:533:18)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:875:27)
at Function.Module._load (internal/modules/cjs/loader.js:745:27)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.<anonymous> (D:\projects\Beauty\node_modules\parse-json\index.js:3:18)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
Run Code Online (Sandbox Code Playgroud)
环境:
操作系统:Windows 10
本机反应:0.65.1
节点:14.17.4
npm:7.23.0
小智 31
首先使用此命令安装节点模块
npm install --force
Run Code Online (Sandbox Code Playgroud)
之后使用
npx react-native run-android
Run Code Online (Sandbox Code Playgroud)
用于运行项目
小智 15
今天早些时候发生在我身上,因为 npm 和纱线包管理器之间的混合,一个简单的npm install解决了这个问题。无需包含--force标志。
nx monorepo我仅针对特定应用程序(而不是其他应用程序)获得此信息。上述方法都不适合我。终于想到了这一点——
太长了;
node_modules/@react-native-community/cli/build/index.jsOR node_modules/react-native/node_modules/@react-native-community/cli/build/index.js。可以肯定的是,您可以在 node_modules 目录中运行此命令:find . -name '*.js' -print0 | xargs -0 grep "Failed to load configuration of your project"
2. 编辑这些文件以打印底层错误。
} catch (error) {
/**
* When there is no `package.json` found, the CLI will enter `detached` mode and a subset
* of commands will be available. That's why we don't throw on such kind of error.
*/
if (error.message.includes("We couldn't find a package.json")) {
_cliTools().logger.debug(error.message);
_cliTools().logger.debug('Failed to load configuration of your project. Only a subset of commands will be available.');
} else {
//---> ***** Print the underlying error!
console.log('=============>', error);
throw new (_cliTools().CLIError)('Failed to load configuration of your project.', error);
}
}
Run Code Online (Sandbox Code Playgroud)
=============> [CLIError: Node module directory for package react-native-animated-pagination-dots was not found]yarn add react-native-animated-pagination-dots。如果只有 CLI 打印了这个潜在的错误,我就可以节省几个小时了!:-/更长的解释
在升级我的 monorepo 时,我不知何故遇到了一种情况,其中一个包从我的 packages.json 中删除,大概是因为纱线无法解析它(在我的情况下,这个包是react-native-animated-pagination-dots)。然后,具有此依赖项的应用程序开始出现此错误,而其他应用程序则没有。
| 归档时间: |
|
| 查看次数: |
45569 次 |
| 最近记录: |