任务 ':app:bundleDevReleaseJsAndAssets' 执行失败

Execution failed for task ':app:bundleDevReleaseJsAndAssets'

当我 运行 我的 Jenkins 为我的 React Native 项目构建时,它失败并出现以下错误:

Unable to resolve module `reactotron-core-client` from `/Users/nfib/Jenkins/Jenkins-Workspaces/ENGA/ENGAL/node_modules/reactotron-redux/dist/index.js`: Module does not exist in the module map

Execution failed for task ':app:bundleDevReleaseJsAndAssets'.

我遵循了推荐的 rm -rf node_modules && npm install,但我不确定这是否有帮助,因为在我看来它像是来自 npm 团队的通用解决方案。

React-Native 版本:0.53.3 "reactotron-react-native": "3.5.0", "reactotron-redux": "3.1.0",

有没有人遇到过类似的问题?我怎样才能确保这种情况不会继续发生?

问题是您的 Jenkins 构建服务器无法找到完成 Jenkins 构建所必需的 reactotron-core-client 模块。您可以从堆栈跟踪中看到这一点:

Unable to resolve module reactotron-core-client

npm 团队的推荐解决方案:

rm -rf node_modules && npm install

是一个通用解决方案,因为此命令将删除您之前包含项目依赖项的 node_modules 目录,然后在项目的 package.json 文件中重新安装列出的依赖项。如果 npm 已在您的构建服务器上更新,这可能会解决由您的锁定文件引起的问题以及版本控制问题。

如果您的 package.json 文件中列出了项目所需的所有库,则此解决方案可能会解决您的问题。但是,如果 reactotron-core-client 库未在您的 package.json 文件中列为必需的依赖项,则此问题将继续存在。或许您可以尝试以下方法:

npm i --save reactotron-core-client

因为这将为您的项目保存并安装 reactotron-core-client 依赖项。通过保存,我的意思是将此库列为 package.json 文件中的依赖项。

理想情况下,向前推进你最好的选择是将你的 package.json 文件 up-to-date 与项目的依赖项一起保存,并在尝试 Jenkins 之前安装依赖项构建.

希望对您有所帮助!