javascript—尝试在netlify上部署我在本地主机上创建的react应用程序,但在尝试部署时出错

r6l8ljro  于 2021-09-13  发布在  Java
关注(0)|答案(1)|浏览(352)

我已经在本地主机上创建了一个react应用程序,并将其推送到我的github存储库中,但是现在我想在netlify上部署它,我得到了这个错误。下面是日志的一部分,其中包含一些错误。请帮助我:(。顺便说一下,代码在本地主机上平稳运行。

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
30byixjq

30byixjq1#

只需阅读您的错误日志:

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 在你的控制台里。

相关问题