javascript - 尝试在本地主机上创建的 Netlify 上部署我的反应应用程序,但在尝试部署时出错
问题描述
我已经在我的本地主机上创建了一个反应应用程序并将其推送到我的 github 存储库中,但是现在我想在 Netlify 上部署它,我得到了这个错误。这是包含一些错误的日志的一部分。plzzzzzzzz 帮帮我:(。顺便说一句,代码在本地主机上运行顺利。
7:50:52 PM: 1. Build command from Netlify app
7:50:52 PM: ────────────────────────────────────────────────────────────────
7:50:52 PM:
7:50:52 PM: $ npm run build
7:50:52 PM: > project@0.1.0 build /opt/build/repo
7:50:52 PM: > react-scripts build
7:50:54 PM: Creating an optimized production build...
7:50:56 PM: Failed to compile.
7:50:56 PM:
7:50:56 PM: ./src/App.js
7:50:56 PM: Cannot find module: 'react-router-dom'. Make sure this package is installed.
7:50:56 PM: You can install this package by running: yarn add react-router-dom.
7:50:56 PM: npm ERR! code ELIFECYCLE
7:50:56 PM: npm ERR! errno 1
7:50:56 PM: npm ERR! project@0.1.0 build: `react-scripts build`
7:50:56 PM: npm ERR! Exit status 1
7:50:56 PM: npm ERR!
7:50:56 PM: npm ERR! Failed at the project@0.1.0 build script.
7:50:56 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
7:50:56 PM: npm ERR! A complete log of this run can be found in:
7:50:56 PM: npm ERR! /opt/buildhome/.npm/_logs/2021-07-08T15_20_56_695Z-debug.log
7:50:56 PM:
7:50:56 PM: ────────────────────────────────────────────────────────────────
7:50:56 PM: "build.command" failed
7:50:56 PM: ────────────────────────────────────────────────────────────────
7:50:56 PM:
7:50:56 PM: Error message
7:50:56 PM: Command failed with exit code 1: npm run build
7:50:56 PM:
7:50:56 PM: Error location
7:50:56 PM: In Build command from Netlify app:
7:50:56 PM: npm run build
7:50:56 PM:
7:50:56 PM: Resolved config
7:50:56 PM: build:
7:50:56 PM: command: npm run build
7:50:56 PM: commandOrigin: ui
7:50:56 PM: publish: /opt/build/repo/build
7:50:56 PM: publishOrigin: ui
7:50:56 PM: functions:
7:50:56 PM: '*': {}
7:50:57 PM: Caching artifacts
7:50:57 PM: Started saving node modules
7:50:57 PM: Finished saving node modules
7:50:57 PM: Started saving build plugins
7:50:57 PM: Finished saving build plugins
7:50:57 PM: Started saving yarn cache
7:50:57 PM: Finished saving yarn cache
7:50:57 PM: Started saving pip cache
7:50:57 PM: Finished saving pip cache
7:50:57 PM: Started saving emacs cask dependencies
7:50:57 PM: Finished saving emacs cask dependencies
7:50:57 PM: Started saving maven dependencies
7:50:57 PM: Finished saving maven dependencies
7:50:57 PM: Started saving boot dependencies
7:50:57 PM: Finished saving boot dependencies
7:50:57 PM: Started saving rust rustup cache
7:50:57 PM: Finished saving rust rustup cache
7:50:57 PM: Started saving go dependencies
7:50:57 PM: Finished saving go dependencies
7:51:00 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
7:51:00 PM: Creating deploy upload records
7:51:00 PM: Failing build: Failed to build site
7:51:00 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
7:51:00 PM: Finished processing build request in 54.583388691s
解决方案
只需阅读您拥有的错误日志:
Cannot find module: 'react-router-dom'. Make sure this package is installed.
7:50:56 PM: You can install this package by running: yarn add react-router-dom.
确保你的 package.json 文件中有“react-router-dom”。
运行:yarn add react-router-dom
在您的控制台中。
推荐阅读
- excel - 对于列/行中的所有值第 2 部分
- webpack - postcss 不能与 webpack 5 和 sass 结合使用
- javascript - CSS:如何使一列中的两个项目最多占用相同的空间,但是如果一个项目小于另一个项目,则使另一个项目增长?
- python - 如何解码特征的字节值(python)
- amazon-web-services - 如何使用 AWS SageMaker 和 S3 进行对象检测?
- python - 对象没有属性?
- angular - 如何在 Dhtmlx 甘特图中添加滚动并根据计数加载数据
- python - Python从字符串中仅删除特定单词1次
- python - 是否可以有条件地省略一些产生的值?
- github - Github 解决冲突总是将基础分支合并到我当前的分支