Once again i am a little out of my depth.
I am struggling with the deployment of my app on Heroku. I think i know 1 possible causes for my issues but I have no idea on how to fix it. I have a structure like:
|app
----|frontend
----|backend
----Procfile
My server.js file is in a "backend" folder and my build is in the "frontend", i saw somebody else on another post mention that you can't import when deployed, it would need to be caught in the build. I can't run the npm run build
in the app directory though.
Within Procfile:
web: node backend/server.js
My second question is about node in the procfile? I use NPM start in my local app, is node still correct for this? Can anybody give me suggestions on how to fix this?
After creating extra config vars for the backend to be accepted heroku errors are:
2020-11-14T17:54:47.586391+00:00 app[web.1]: > notd-server@1.0.0 start /app
2020-11-14T17:54:47.586391+00:00 app[web.1]: > nodemon --watch backend --exec node --experimental-modules backend/server.js
2020-11-14T17:54:47.586392+00:00 app[web.1]:
2020-11-14T17:54:47.591182+00:00 app[web.1]: sh: 1: nodemon: not found
2020-11-14T17:54:47.594512+00:00 app[web.1]: npm ERR! file sh
2020-11-14T17:54:47.594706+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2020-11-14T17:54:47.594847+00:00 app[web.1]: npm ERR! errno ENOENT
2020-11-14T17:54:47.594972+00:00 app[web.1]: npm ERR! syscall spawn
2020-11-14T17:54:47.595832+00:00 app[web.1]: npm ERR! notd-server@1.0.0 start: `nodemon --watch backend --exec node --experimental-modules backend/server.js`
2020-11-14T17:54:47.595924+00:00 app[web.1]: npm ERR! spawn ENOENT
2020-11-14T17:54:47.596050+00:00 app[web.1]: npm ERR!
2020-11-14T17:54:47.596145+00:00 app[web.1]: npm ERR! Failed at the notd-server@1.0.0 start script.
2020-11-14T17:54:47.596232+00:00 app[web.1]: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2020-11-14T17:54:47.603840+00:00 app[web.1]:
2020-11-14T17:54:47.604047+00:00 app[web.1]: npm ERR! A complete log of this run can be found in:
2020-11-14T17:54:47.604184+00:00 app[web.1]: npm ERR! /app/.npm/_logs/2020-11-14T17_54_47_597Z-debug.log
package.json
{
"name": "notd-server",
"version": "1.0.0",
"description": "server side for NOTD web app",
"main": "index.js",
"scripts": {
"start": "nodemon --watch backend --exec node --experimental-modules backend/server.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Eldoddo/NOTD-Dev.git"
},
"author": "EDodd",
"license": "ISC",
"bugs": {
"url": "https://github.com/Eldoddo/NOTD-Dev/issues"
},
"homepage": "https://github.com/Eldoddo/NOTD-Dev#readme",
"dependencies": {
"body-parser": "^1.19.0",
"dotenv": "^8.2.0",
"express-async-handler": "^1.1.4",
"jsonwebtoken": "^8.5.1",
"mongoose": "^5.10.11"
},
"devDependencies": {
"@babel/cli": "^7.12.1",
"@babel/core": "^7.12.3",
"@babel/node": "^7.12.1",
"@babel/preset-env": "^7.12.1",
"nodemon": "^2.0.6"
},
"engines": {
"node": "12.4.0",
"npm": "6.9.0"
}
}
Much appreciated.