I am trying to deploy an app i built with django backend serving API's to a Vue.js frontend to Heroku. Everything works well locally. On Heroku, i have done the setup by adding heroku/nodejs and heroku/python buildpacks. I have also added my app Config Var secret key on heroku settings. My vuejs frontend package.js script looks like this;
"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"
},
When i try to push to heroku with git push heroku master, the build fails with error that the main.js module was not found. However, there is main.js file in my frontend. While googling about this issue, i saw a similar issue which turned out to be that the entry in webpack config file was not set, but in my own case, in webpack.js i have entry set like so;
entry: {
app: [
'./src/main.js'
]
}
I have also re-installed all my modules as suggested in one of the help resources, still it doesn't resolve the issue. Here is a full trace of the build error;
-----> 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
Someone kindly have a look to see what i'm doing wrong.