【发布时间】:2019-11-15 06:24:18
【问题描述】:
我正在尝试部署我的应用程序,但无法正常工作。 我的 package.json 脚本:
"scripts": {
"serve": "live-server public --port=8091",
"build": "webpack",
"dev-server": "webpack-dev-server",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
运行 npm run deploy 时出错:
ENOENT: no such file or directory, stat 'C:\Users\Luiz\Desktop\udemy\react-course-projects\indecision-app\build'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! indecision-app@1.0.0 deploy: `gh-pages -d build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the indecision-app@1.0.0 deploy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
【问题讨论】:
-
webpack是如何配置的?它是否输出到名为build/的项目根目录下?看起来serve期望它位于public/... -
输出:{ path: path.join(__dirname, "public"), filename: "bundle.js" }
-
那你为什么要从
build/部署?阅读错误信息:no such file or directory, stat '...\build'. -
现在它可以工作了,但是laurabeatris.github.io/indecision 没有显示任何东西
-
查看浏览器的“网络”选项卡 - 它正在寻找 laurabeatris.github.io/bundle.js,但这是一个 404,因为捆绑包是在 laurabeatris.github.io/indecision/bundle.js 提供的。你需要更新你的 Webpack 配置以确保它在它生成的链接中进行调整。
标签: reactjs git github-pages