Search code examples
mongodbexpressherokuhandlebars.js

Heroku push rejected failed: npm ERR! 404 Not Found: [email protected]. This causes a build fail


I am getting the error:

Heroku push rejected failed to define node.js node not defined in package.json

My app works locally, this is an Express MongoDB using handlebars. My gitignore has node_modules in it and the strange part is I am using nodemon and not node.

package.json:

{
"name": "Jukebox",
"version": "1.1.0",
"engines": {
    "node": "11.3.0",
    "npm": "6.4.1"
},
"private": true,
"scripts": {
"start": "node ./bin/www",
"dev": "nodemon ./bin/www"
},
"dependencies": {
"cookie-parser": "~1.4.3",
"debug": "~2.6.9",
"dotenv": "^6.1.0",
"express": "~4.16.0",
"hbs": "~4.0.1",
"http-errors": "~1.6.2",
"method-override": "^3.0.0",
"mongoose": "^5.3.6",
"morgan": "~1.9.0",
"nodemon": "^1.18.4"
},
"description": "Jukebox is an app where users can add their favorite songs for others to discover. There will be a maximum number of 32 songs that can be added. When user selects genre the artists of that genre will populate the grid and a button will appear to add artist.",
"main": "app.js",
"repository": {
    "type": "git",
    "url": "git+https://github.com/chuckderosier/Jukebox.git"
},
"author": "",
"license": "ISC",
"bugs": {
    "url": "https://github.com/chuckderosier/Jukebox/issues"
},
"homepage": "https://github.com/chuckderosier/Jukebox#readme"

}


Solution

  • You need to specify a Node.js version within your package.json that matches the runtime you’re developing and testing with.

    Do the following:

    1. Within your cmd line type: node --version and see what version of Node you're developing with.
    2. Add an engines section within your package.json specifying your node version from step 1. For example something similar to this:

    "engines": { "node": "10.3.0" }

    For more information checkout the Heroku documentation for Nodejs buildpacks