我正在尝试将使用Django后端服务API构建的应用程序部署到Heroku的Vue.js前端。本地一切正常。在Heroku上,我通过添加heroku / nodejs和heroku / python buildpacks完成了设置。我还在heroku设置上添加了我的应用程序Config Var密钥。我的vuejs前端package.js脚本如下所示:
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint",
"postinstall": "npm run build",
"heroku-prebuild": "export NPM_CONFIG_PRODUCTION=false; export NODE_ENV=; NPM_CONFIG_PRODUCTION=false NODE_ENV=development npm install --only=dev --dev",
"heroku-postbuild": "npm run prod",
"start": "npm run dev"
},
当我尝试使用git push heroku master推送到heroku时,构建失败,并出现错误,找不到main.js模块。但是,我的前端中有main.js文件。在搜寻这个问题时,我看到了一个类似的问题,结果是未设置webpack配置文件中的条目,但就我个人而言,在webpack.js中我的条目设置是这样的;
entry: {
app: [
'./src/main.js'
]
}
我还按照帮助资源之一的建议重新安装了所有模块,但仍然不能解决问题。 这是构建错误的完整记录;
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): 10.x
engines.npm (package.json): unspecified (use default)
Resolving node version 10.x...
Downloading and installing node 10.22.0...
Using default npm version: 6.14.6
-----> Installing dependencies
Installing node modules (package.json)
> yorkie@2.0.0 install /tmp/build_9f0e2037/node_modules/yorkie
> node bin/install.js
setting up Git hooks
can't find .git directory, skipping Git hooks installation
> core-js@3.6.5 postinstall /tmp/build_9f0e2037/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> ejs@2.7.4 postinstall /tmp/build_9f0e2037/node_modules/ejs
> node ./postinstall.js
added 1294 packages from 879 contributors and audited 1297 packages in 36.823s
55 packages are looking for funding
run `npm fund` for details
found 1 high severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
-----> Build
Running build
> client@0.1.0 build /tmp/build_9f0e2037
> vue-cli-service build
- Building for production...
ERROR Failed to compile with 1 errors8:06:33 AM
This relative module was not found:
* ./src/main.js in multi ./src/main.js
ERROR Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client@0.1.0 build: `vue-cli-service build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.OgbJX/_logs/2020-08-17T08_06_33_409Z-debug.log
-----> Build failed
We're sorry this build is failing! You can troubleshoot common issues here:
https://devcenter.heroku.com/articles/troubleshooting-node-deploys
If you're stuck, please submit a ticket so we can help:
https://help.heroku.com/
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed
有人请看看我在做什么错。