我刚刚通过为每个组件及其.js和.scss文件创建一个文件夹来重构我的应用程序,并且在本地运行良好(甚至是npm run build命令)。 现在的问题是,当我尝试部署它时,它给了我一个错误。 它说
5:25:44 PM: ./src/Components/restaurants/RestaurantInfo/RestaurantInfo.js
5:25:44 PM: Cannot find file '../../util/Review' in './src/Components/restaurants/RestaurantInfo'.
它找不到它,因为./src/Components/restaurants/RestaurantInfo
现在只是一个文件夹,它应该检查./src/Components/restaurants/RestaurantInfo/RestaurantInfo
。
我已经检查了所有路径,并且是正确的,正如我在本地所说的那样,一切正常,但显然出了点问题,我无法弄清。
以下是其网址:https://restaurant-finder-redux.netlify.app/ Github存储库:https://github.com/mugg84/RestaurantFinderRedux.git 和完整的错误:
5:25:41 PM: Build ready to start
5:25:43 PM: build-image version: ca811f47d4c1cbd1812d1eb6ecb0c977e86d1a1d
5:25:43 PM: build-image tag: v3.3.20
5:25:43 PM: buildbot version: be8ecf2af866e16fa4301cc5c14de2ccbbb21cf4
5:25:43 PM: Fetching cached dependencies
5:25:43 PM: Starting to download cache of 254.8KB
5:25:43 PM: Finished downloading cache in 74.189736ms
5:25:43 PM: Starting to extract cache
5:25:43 PM: Failed to fetch cache, continuing with build
5:25:43 PM: Starting to prepare the repo for build
5:25:44 PM: No cached dependencies found. Cloning fresh repo
5:25:44 PM: git clone git@github.com:mugg84/RestaurantFinderRedux
5:25:45 PM: Preparing Git Reference refs/heads/master
5:25:47 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'build' versus 'C:\Users\Turi\Desktop\project\RestaurantsRedux\build' in the Netlify UI
5:25:47 PM: Starting build script
5:25:47 PM: Installing dependencies
5:25:47 PM: Python version set to 2.7
5:25:48 PM: v12.18.0 is already installed.
5:25:49 PM: Now using node v12.18.0 (npm v6.14.4)
5:25:49 PM: Started restoring cached build plugins
5:25:49 PM: Finished restoring cached build plugins
5:25:49 PM: Attempting ruby version 2.7.1, read from environment
5:25:51 PM: Using ruby version 2.7.1
5:25:51 PM: Using PHP version 5.6
5:25:51 PM: 5.2 is already installed.
5:25:51 PM: Using Swift version 5.2
5:25:51 PM: Started restoring cached node modules
5:25:51 PM: Finished restoring cached node modules
5:25:51 PM: Installing NPM modules using NPM version 6.14.4
5:26:28 PM: > node-sass@4.14.1 install /opt/build/repo/node_modules/node-sass
5:26:28 PM: > node scripts/install.js
5:26:29 PM: Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/linux-x64-72_binding.node
5:26:29 PM: Download complete
5:26:29 PM: Binary saved to /opt/build/repo/node_modules/node-sass/vendor/linux-x64-72/binding.node
5:26:29 PM: Caching binary to /opt/buildhome/.npm/node-sass/4.14.1/linux-x64-72_binding.node
5:26:30 PM: > core-js@2.6.11 postinstall /opt/build/repo/node_modules/babel-runtime/node_modules/core-js
5:26:30 PM: > node -e "try{require('./postinstall')}catch(e){}"
5:26:30 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/core-js
5:26:30 PM: > node -e "try{require('./postinstall')}catch(e){}"
5:26:30 PM: > core-js-pure@3.6.5 postinstall /opt/build/repo/node_modules/core-js-pure
5:26:30 PM: > node -e "try{require('./postinstall')}catch(e){}"
5:26:31 PM: > node-sass@4.14.1 postinstall /opt/build/repo/node_modules/node-sass
5:26:31 PM: > node scripts/build.js
5:26:31 PM: Binary found at /opt/build/repo/node_modules/node-sass/vendor/linux-x64-72/binding.node
5:26:31 PM: Testing binary
5:26:31 PM: Binary is fine
5:26:33 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
5:26:33 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:26:33 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
5:26:33 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:26:33 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/jest-haste-map/node_modules/fsevents):
5:26:33 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:26:33 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules/fsevents):
5:26:33 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:26:33 PM: added 1778 packages from 828 contributors and audited 1782 packages in 40.593s
5:26:35 PM: 60 packages are looking for funding
5:26:35 PM: run `npm fund` for details
5:26:35 PM: found 4985 low severity vulnerabilities
5:26:35 PM: run `npm audit fix` to fix them, or `npm audit` for details
5:26:35 PM: NPM modules installed
5:26:35 PM: Started restoring cached go cache
5:26:35 PM: Finished restoring cached go cache
5:26:35 PM: go version go1.14.4 linux/amd64
5:26:35 PM: go version go1.14.4 linux/amd64
5:26:35 PM: Installing missing commands
5:26:35 PM: Verify run directory
5:26:37 PM:
5:26:37 PM: ┌─────────────────────────────┐
5:26:37 PM: │ Netlify Build │
5:26:37 PM: └─────────────────────────────┘
5:26:37 PM:
5:26:37 PM: ❯ Version
5:26:37 PM: @netlify/build 3.0.1
5:26:37 PM:
5:26:37 PM: ❯ Flags
5:26:37 PM: deployId: 5f19ba059db363022d8ef5d1
5:26:37 PM: mode: buildbot
5:26:37 PM:
5:26:37 PM: ❯ Current directory
5:26:37 PM: /opt/build/repo
5:26:37 PM:
5:26:37 PM: ❯ Config file
5:26:37 PM: /opt/build/repo/netlify.toml
5:26:37 PM:
5:26:37 PM: ❯ Context
5:26:37 PM: production
5:26:37 PM:
5:26:37 PM: ┌───────────────────────────────────┐
5:26:37 PM: │ 1. Build command from Netlify app │
5:26:37 PM: └───────────────────────────────────┘
5:26:37 PM:
5:26:37 PM: $ npm run build
5:26:37 PM: > RestaurantFinder@0.1.0 build /opt/build/repo
5:26:37 PM: > react-scripts build
5:26:38 PM: Creating an optimized production build...
5:26:44 PM: Failed to compile.
5:26:44 PM:
5:26:44 PM: ./src/Components/restaurants/RestaurantInfo/RestaurantInfo.js
5:26:44 PM: Cannot find file '../../util/Review' in './src/Components/restaurants/RestaurantInfo'.
5:26:44 PM: npm ERR! code ELIFECYCLE
5:26:44 PM: npm ERR! errno 1
5:26:44 PM: npm ERR! RestaurantFinder@0.1.0 build: `react-scripts build`
5:26:44 PM: npm ERR! Exit status 1
5:26:44 PM: npm ERR!
5:26:44 PM: npm ERR! Failed at the RestaurantFinder@0.1.0 build script.
5:26:44 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
5:26:44 PM: npm ERR! A complete log of this run can be found in:
5:26:44 PM: npm ERR! /opt/buildhome/.npm/_logs/2020-07-23T16_26_44_363Z-debug.log
5:26:44 PM:
5:26:44 PM: If the build failed with a warning about "process.env.CI = true", this is due to "create-react-app" treating warnings as errors when in CI. In order to fix this problem, please either:
5:26:44 PM: - Fix the issues highlighted by the warnings above.
5:26:44 PM: - Or modify the "scripts.build" command in your "package.json" from "react-scripts build" to "CI= react-scripts build"
5:26:44 PM: More information can be found at https://docs.netlify.com/configure-builds/troubleshooting-tips/#build-fails-on-warning-message
5:26:44 PM:
5:26:44 PM: ┌─────────────────────────────┐
5:26:44 PM: │ "build.command" failed │
5:26:44 PM: └─────────────────────────────┘
5:26:44 PM:
5:26:44 PM: Error message
5:26:44 PM: Command failed with exit code 1: npm run build
5:26:44 PM:
5:26:44 PM: Error location
5:26:44 PM: In Build command from Netlify app:
5:26:44 PM: npm run build
5:26:44 PM:
5:26:44 PM: Resolved config
5:26:44 PM: build:
5:26:44 PM: command: npm run build
5:26:44 PM: commandOrigin: ui
5:26:44 PM: environment:
5:26:44 PM: - REACT_APP_GOOGLE_API_KEY
5:26:44 PM: - REACT_APP_MAILCHIMP_URL
5:26:44 PM: - REACT_APP_YELP_API_KEY
5:26:44 PM: publish: /opt/build/repo/build
5:26:44 PM: Caching artifacts
5:26:44 PM: Started saving node modules
5:26:44 PM: Finished saving node modules
5:26:44 PM: Started saving build plugins
5:26:44 PM: Finished saving build plugins
5:26:44 PM: Started saving pip cache
5:26:44 PM: Finished saving pip cache
5:26:44 PM: Started saving emacs cask dependencies
5:26:44 PM: Finished saving emacs cask dependencies
5:26:44 PM: Started saving maven dependencies
5:26:44 PM: Finished saving maven dependencies
5:26:44 PM: Started saving boot dependencies
5:26:44 PM: Finished saving boot dependencies
5:26:44 PM: Started saving go dependencies
5:26:44 PM: Finished saving go dependencies
5:26:47 PM: Error running command: Build script returned non-zero exit code: 1
5:26:47 PM: Failing build: Failed to build site
5:26:47 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1
5:26:47 PM: Finished processing build request in 1m4.47397412s
感谢您的帮助!
答案 0 :(得分:0)
问题是一个文件夹的存储库名称与本地文件夹(特别是文件夹util
)之间的差异。
在存储库中,它是大写的Util
,而在本地util
中是大问题。
这说明了为什么本地npm run build
有点无法部署。