在 netlify 上部署构建时出错(错误:1)
Error deploying build on netlify (err: 1)
我通过 GitHub 在 Netlify 上部署了一个网站,在提交一些更改后,Netlify 无法部署当前版本。
我没有从 运行 'npm run build' 或 运行 本地代码中得到任何错误。
该网站是使用 create-react-app 构建的。
之前提交的主要变化是将资产(图像)添加到整个项目。
我仔细检查了每个导入,一切正常。
...
5:15:52 PM: Installing NPM modules using NPM version 6.9.0
5:16:05 PM: npm
5:16:05 PM: WARN @typescript-eslint/eslint-plugin@1.6.0 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
5:16:05 PM: npm
5:16:05 PM: WARN @typescript-eslint/parser@1.6.0 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
5:16:05 PM: npm
5:16:05 PM: WARN @typescript-eslint/typescript-estree@1.6.0 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
5:16:05 PM: npm WARN
5:16:05 PM: ts-pnp@1.1.2 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
5:16:05 PM: npm
5:16:05 PM: WARN tsutils@3.14.0 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev but none is installed. You must install peer dependencies yourself.
5:16:05 PM: npm
5:16:05 PM: WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/jest-haste-map/node_modules/fsevents):
5:16:05 PM: npm WARN
5:16:05 PM: notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:16:05 PM: npm
5:16:05 PM: WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/chokidar/node_modules/fsevents):
5:16:05 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:16:05 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.0.6 (node_modules/fsevents):
5:16:05 PM: npm
5:16:05 PM: WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.0.6: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:16:05 PM: audited 902137 packages in 12.338s
5:16:05 PM: found 0 vulnerabilities
5:16:05 PM: NPM modules installed
5:16:06 PM: Started restoring cached go cache
5:16:06 PM: Finished restoring cached go cache
5:16:06 PM: unset GOOS;
5:16:06 PM: unset GOARCH;
5:16:06 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
5:16:06 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
5:16:06 PM: go version >&2;
5:16:06 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
5:16:06 PM: go version go1.12 linux/amd64
5:16:06 PM: Installing missing commands
5:16:06 PM: Verify run directory
5:16:06 PM: Executing user command: npm run build
5:16:07 PM: > geek-hard-level@0.1.0 build /opt/build/repo
5:16:07 PM: > react-scripts build
5:16:09 PM: Creating an optimized production build...
5:16:14 PM: Failed to compile.
5:16:14 PM: ./src/components/footer/footer.js
5:16:14 PM: Cannot find file '../../assets/images/Logo.jpg' in './src/components/footer'.
5:16:14 PM: npm
5:16:14 PM: ERR! code ELIFECYCLE
5:16:14 PM: npm
5:16:14 PM: ERR! errno 1
5:16:14 PM: npm
5:16:14 PM: ERR! geek-hard-level@0.1.0 build: `react-scripts build`
5:16:14 PM: npm
5:16:14 PM: ERR!
5:16:14 PM: Exit status 1
5:16:14 PM: npm
5:16:14 PM: ERR!
5:16:14 PM: npm ERR!
5:16:14 PM: Failed at the geek-hard-level@0.1.0 build script.
5:16:14 PM: npm
5:16:14 PM: failed during stage 'building site': Build script returned non-zero exit code: 1
5:16:14 PM: ERR! This is probably not a problem with npm. There is likely additional logging output above.
5:16:14 PM: npm
5:16:14 PM: ERR! A complete log of this run can be found in:
5:16:14 PM: npm ERR! /opt/buildhome/.npm/_logs/2019-07-14T16_16_14_542Z-debug.log
5:16:14 PM: Skipping functions preparation step: no functions directory set
5:16:14 PM: Caching artifacts
5:16:14 PM: Started saving node modules
5:16:14 PM: Finished saving node modules
5:16:14 PM: Started saving pip cache
5:16:14 PM: Finished saving pip cache
5:16:14 PM: Started saving emacs cask dependencies
5:16:14 PM: Finished saving emacs cask dependencies
5:16:14 PM: Started saving maven dependencies
5:16:14 PM: Finished saving maven dependencies
5:16:14 PM: Started saving boot dependencies
5:16:14 PM: Finished saving boot dependencies
5:16:14 PM: Started saving go dependencies
5:16:14 PM: Finished saving go dependencies
5:16:14 PM: Error running command: Build script returned non-zero exit code: 1
5:16:14 PM: Failing build: Failed to build site
5:16:14 PM: Finished processing build request in 36.62159852s
我希望构建能够像往常一样部署,但我收到错误
5:16:14 PM: Cannot find file '../../assets/images/Logo.jpg' in './src/components/footer'.```
I did check this line and it works just fine.
Edit:
Trying to re-deploy the code it throws me the same error but this time instead of being in /components/footer is in /components/contacts, where there is the same Logo.jpg file
```5:31:09 PM: ./src/components/contacts/contacts.js
5:31:09 PM: Cannot find file '../../assets/images/Logo.jpg' in './src/components/contacts'.
将您的图像资源移动到 React 默认附带的 public 文件夹中,并优化您正在使用的路径,例如:
import image from '../../public/images/Logo.jpg'
Sultan H. 回答部分正确。
我通过将图像文件夹移动到组件的同一文件夹中解决了我的问题。尽管我认为这不是一个好的做法,但 Netlify 成功地发布了它。
如果我必须将 images 文件夹移动到 public 里面,它会抛出一个新的错误。
快速查看这个新错误,它应该与 create-react-app 有关,它不允许从 src 之外的任何文件夹导入任何内容。
我通过 GitHub 在 Netlify 上部署了一个网站,在提交一些更改后,Netlify 无法部署当前版本。 我没有从 运行 'npm run build' 或 运行 本地代码中得到任何错误。 该网站是使用 create-react-app 构建的。 之前提交的主要变化是将资产(图像)添加到整个项目。 我仔细检查了每个导入,一切正常。
...
5:15:52 PM: Installing NPM modules using NPM version 6.9.0
5:16:05 PM: npm
5:16:05 PM: WARN @typescript-eslint/eslint-plugin@1.6.0 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
5:16:05 PM: npm
5:16:05 PM: WARN @typescript-eslint/parser@1.6.0 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
5:16:05 PM: npm
5:16:05 PM: WARN @typescript-eslint/typescript-estree@1.6.0 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
5:16:05 PM: npm WARN
5:16:05 PM: ts-pnp@1.1.2 requires a peer of typescript@* but none is installed. You must install peer dependencies yourself.
5:16:05 PM: npm
5:16:05 PM: WARN tsutils@3.14.0 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev but none is installed. You must install peer dependencies yourself.
5:16:05 PM: npm
5:16:05 PM: WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/jest-haste-map/node_modules/fsevents):
5:16:05 PM: npm WARN
5:16:05 PM: notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:16:05 PM: npm
5:16:05 PM: WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/chokidar/node_modules/fsevents):
5:16:05 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:16:05 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.0.6 (node_modules/fsevents):
5:16:05 PM: npm
5:16:05 PM: WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.0.6: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:16:05 PM: audited 902137 packages in 12.338s
5:16:05 PM: found 0 vulnerabilities
5:16:05 PM: NPM modules installed
5:16:06 PM: Started restoring cached go cache
5:16:06 PM: Finished restoring cached go cache
5:16:06 PM: unset GOOS;
5:16:06 PM: unset GOARCH;
5:16:06 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
5:16:06 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
5:16:06 PM: go version >&2;
5:16:06 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
5:16:06 PM: go version go1.12 linux/amd64
5:16:06 PM: Installing missing commands
5:16:06 PM: Verify run directory
5:16:06 PM: Executing user command: npm run build
5:16:07 PM: > geek-hard-level@0.1.0 build /opt/build/repo
5:16:07 PM: > react-scripts build
5:16:09 PM: Creating an optimized production build...
5:16:14 PM: Failed to compile.
5:16:14 PM: ./src/components/footer/footer.js
5:16:14 PM: Cannot find file '../../assets/images/Logo.jpg' in './src/components/footer'.
5:16:14 PM: npm
5:16:14 PM: ERR! code ELIFECYCLE
5:16:14 PM: npm
5:16:14 PM: ERR! errno 1
5:16:14 PM: npm
5:16:14 PM: ERR! geek-hard-level@0.1.0 build: `react-scripts build`
5:16:14 PM: npm
5:16:14 PM: ERR!
5:16:14 PM: Exit status 1
5:16:14 PM: npm
5:16:14 PM: ERR!
5:16:14 PM: npm ERR!
5:16:14 PM: Failed at the geek-hard-level@0.1.0 build script.
5:16:14 PM: npm
5:16:14 PM: failed during stage 'building site': Build script returned non-zero exit code: 1
5:16:14 PM: ERR! This is probably not a problem with npm. There is likely additional logging output above.
5:16:14 PM: npm
5:16:14 PM: ERR! A complete log of this run can be found in:
5:16:14 PM: npm ERR! /opt/buildhome/.npm/_logs/2019-07-14T16_16_14_542Z-debug.log
5:16:14 PM: Skipping functions preparation step: no functions directory set
5:16:14 PM: Caching artifacts
5:16:14 PM: Started saving node modules
5:16:14 PM: Finished saving node modules
5:16:14 PM: Started saving pip cache
5:16:14 PM: Finished saving pip cache
5:16:14 PM: Started saving emacs cask dependencies
5:16:14 PM: Finished saving emacs cask dependencies
5:16:14 PM: Started saving maven dependencies
5:16:14 PM: Finished saving maven dependencies
5:16:14 PM: Started saving boot dependencies
5:16:14 PM: Finished saving boot dependencies
5:16:14 PM: Started saving go dependencies
5:16:14 PM: Finished saving go dependencies
5:16:14 PM: Error running command: Build script returned non-zero exit code: 1
5:16:14 PM: Failing build: Failed to build site
5:16:14 PM: Finished processing build request in 36.62159852s
我希望构建能够像往常一样部署,但我收到错误
5:16:14 PM: Cannot find file '../../assets/images/Logo.jpg' in './src/components/footer'.```
I did check this line and it works just fine.
Edit:
Trying to re-deploy the code it throws me the same error but this time instead of being in /components/footer is in /components/contacts, where there is the same Logo.jpg file
```5:31:09 PM: ./src/components/contacts/contacts.js
5:31:09 PM: Cannot find file '../../assets/images/Logo.jpg' in './src/components/contacts'.
将您的图像资源移动到 React 默认附带的 public 文件夹中,并优化您正在使用的路径,例如:
import image from '../../public/images/Logo.jpg'
Sultan H. 回答部分正确。
我通过将图像文件夹移动到组件的同一文件夹中解决了我的问题。尽管我认为这不是一个好的做法,但 Netlify 成功地发布了它。 如果我必须将 images 文件夹移动到 public 里面,它会抛出一个新的错误。 快速查看这个新错误,它应该与 create-react-app 有关,它不允许从 src 之外的任何文件夹导入任何内容。