Netify持续出现构建错误的主机问题

huangapple go评论63阅读模式
英文:

hosting issue in netify continously having build error

问题

错误日志:

11:04:01 AM: 编译失败。
11:04:01 AM: 
11:04:01 AM: 未找到模块:错误:无法解析 '/opt/build/repo/src/components/Portfolio2' 中的 'C:\Users\LG\Desktop\React\my-app\src\components\Portfolio\assets\video1.mp4'
11:04:02 AM: ​
11:04:02 AM: “build.command”失败
11:04:02 AM: ────────────────────────────────────────────────────────────────
11:04:02 AM: ​
11:04:02 AM:   错误消息
11:04:02 AM:   命令退出码为1:npm run build (https://ntl.fyi/exit-code-1)
11:04:02 AM: ​
11:04:02 AM:   错误位置
11:04:02 AM:   在Netlify应用的构建命令中:
11:04:02 AM:   npm run build
11:04:02 AM: ​
11:04:02 AM:   解析的配置
11:04:02 AM:   构建:
11:04:02 AM:     命令:npm run build
11:04:02 AM:     命令来源:ui
11:04:02 AM:     发布:/opt/build/repo/build
11:04:02 AM:     发布来源:ui
11:04:03 AM: 阶段“构建站点”期间失败:构建脚本返回了非零退出码:2 (https://ntl.fyi/exit-code-2)
11:04:03 AM: 由于用户错误导致构建失败:构建脚本返回了非零退出码:2
11:04:03 AM: 构建失败:无法构建站点
11:04:03 AM: 在31.714秒内完成构建请求的处理

无法解决这个错误。这个错误一直在我的所有项目中反复发生,有人可以帮忙吗?

英文:

Error Log:

11:04:01 AM: Failed to compile.
11:04:01 AM: 
11:04:01 AM: Module not found: Error: Can't resolve 'C:\Users\LG\Desktop\React\my-app\src\components\Portfolio\assets\video1.mp4' in '/opt/build/repo/src/components/Portfolio2'
11:04:02 AM: ​
11:04:02 AM: "build.command" failed                                        
11:04:02 AM: ────────────────────────────────────────────────────────────────
11:04:02 AM: ​
11:04:02 AM:   Error message
11:04:02 AM:   Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
11:04:02 AM: ​
11:04:02 AM:   Error location
11:04:02 AM:   In Build command from Netlify app:
11:04:02 AM:   npm run build
11:04:02 AM: ​
11:04:02 AM:   Resolved config
11:04:02 AM:   build:
11:04:02 AM:     command: npm run build
11:04:02 AM:     commandOrigin: ui
11:04:02 AM:     publish: /opt/build/repo/build
11:04:02 AM:     publishOrigin: ui
11:04:03 AM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
11:04:03 AM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:04:03 AM: Failing build: Failed to build site
11:04:03 AM: Finished processing build request in 31.714s

Cant resolve this error .It is repetedely happening with all my projects can anyone help

答案1

得分: 2

看起来你是这样导入视频文件的。

import Video from "./assets/video1.mp4";

请不要在文件中包含完整的本地URL。你应该使用这个代替。

英文:

It looks like you are importing the video file like this.

import Video from "C:\Users\LG\Desktop\React\my-app\src\components\Portfolio\assets\video1.mp4"

Please don't include the full local URL in your file. You have to use this instead:

import Video from "./assets/video1.mp4"

huangapple
  • 本文由 发表于 2023年6月9日 13:57:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76437566.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定