I am trying to deploy a web app on Heroku. I am getting the following error
Error: Cannot find module '#heroku/buildpack-registry'
I tried adding the version of node I am using but still didn't help.
I also upgraded Heroku using npm i heroku#7.59.0 this too didn't help.
Any thoughts on this?
This is my package.json
{"name":"gssrDB",
"engines": {
"node": "14.18.0"
}
,
"scripts": {
"dev": "nodemon index.js",
"start": "node index.js"
},
"dependencies": {
"#heroku-cli/plugin-buildpacks": "^7.54.0",
"#heroku/buildpack-registry": "^1.0.1",
"async-file": "^2.0.2",
"cli-ux": "^4.9.3",
"dotenv": "^9.0.2",
"ejs": "^3.1.6",
"ejs-mate": "^3.0.0",
"express": "^4.17.1",
"got": "^8.3.2",
"heroku": "^7.59.0",
"mongodb": "^3.6.6",
"mongoose": "^5.12.9",
"nodemon": "^2.0.13",
"phoenix": "^1.6.0"
}
}
I solved it like this in terminal
$ heroku plugins:install buildpack-registry
$ heroku plugins:install buildpacks
may be it works
I faced a similar problem, and I solved it by using proper node version.
For the current heroku version, node16 works, otherwise it cause error in buildpack
Two things helped in fixing this:
update the heroku CLI
npm install -g heroku
Adding the engines in the package.json with the currently installed node and npm versions
"node": "14.18.0",
"npm": "7.6.3"
}
Related
My Azure app service is running Node.js version 0.10:
> node -v
D:\home\site\wwwroot
v0.10.28
I am trying to upgrade it to version 8.
There's an article here describing how to do that: https://learn.microsoft.com/en-us/azure/nodejs-specify-node-version-azure-apps
First, I added the key in the Application Settings in Azure Portal:
It didn't work, so I also changed packages.json:
{
"name": "azure_cosmos_db_webservice",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node --inspect server.js"
},
"engines":{"node": "8.x"}, <-- This line added by me
"dependencies": {
"async": "^2.1.2",
"body-parser": "~1.15.2",
"cookie-parser": "~1.4.3",
"debug": "~2.2.0",
"documentdb": "^1.10.0",
"dotenv": "^4.0.0",
"express": "~4.14.0",
"morgan": "~1.7.0",
"serve-favicon": "~2.3.0"
}
}
I've restarted the app service several times by stopping and starting it again.
However, node -v in the console in Azure Portal is still showing the version as 0.10.28.
What did I miss?
Turns out that 8.x was not a correct syntax.
I've changed it to 8.1.4 both in packages.json and in the Application Settings, and it worked.
I found the list of supported versions here:
https://MYSITE.scm.azurewebsites.net/api/diagnostics/runtime
I'm new to using gulp and browserify. I'm trying to follow a tutorial online which uses browserify and gulp.
Following is my package.json
{
"name": "progressive",
"version": "1.0.0",
"description": "Practcing a Progressive Web App",
"scripts": {
"start": "node ./index.js"
},
"author": "Indu Pillai",
"devDependencies": {
"browserify": "^13.1.0",
"gulp": "^3.8.8",
"gulp-browserify": "^0.5.1",
"gulp-clean-css": "^2.0.13",
"gulp-concat-css": "^2.3.0",
"gulp-if": "^2.0.1",
"gulp-sourcemaps": "^2.2.0",
"gulp-uglify": "^2.0.0",
"gulp-util": "^2.2.20",
"gulp-webserver": "^0.8.8",
"jquery": "^3.1.1",
"sw-precache": "^4.2.1"
},
"dependencies": {
"handlebars": "^4.0.5"
}
}
When I run npm install, it gives me the following error:
npm WARN browserify-shim#2.0.10 requires a peer of browserify#>= 2.3.0 < 4 but none was installed.
I don't know how to solve this problem, I'm not good at npm stuff either. I didn't ask for browserify-shim in my package.json, but may be some of the packages I asked depends on it.
Thank You!
I have the same problem
and I solve it with the following:
If you use the windows you should
Download the :(Windows Binary.Zip)
Then choose the correct architecture to your computer (32 or 64),
make it active
Open Command Prompt as Administrator
Execute this on the command line: npm install -g #angular/cli
I'm trying to deploy a Node app to Heroku, but I'm having an issue successfully running browserify when the app is deployed.
When I'm running locally, I browserify my script with npm run bundle like so (from package.json):
"bundle": "./node_modules/browserify/bin/cmd.js build/main.js -o public/scripts/bundle.js
which browserifies the script in build/main.js and puts it into public/scripts/bundle.js.
For deploying to Heroku, I added
"postinstall": "npm run bundle"
However, when I deploy, I get the following error:
Error: ENOENT: no such file or directory, open 'public/scripts/bundle.js.tmp-browserify-59309133185877094263'
Well, that's correct, that file shouldn't exist... yet. When I run npm run bundle locally, I do see that file briefly pop into existence, but then it is quickly removed and I'm left with a nice updated bundle.js.
I read through Heroku's docs on this, but I'm miffed... can anyone clarify how to get through this?
For reference, here are the relevant parts of my package.json:
"scripts": {
"bundle": "./node_modules/browserify/bin/cmd.js build/main.js -o public/scripts/bundle.js",
"postinstall": "npm run bundle"
},
"dependencies": {
"body-parser": "^1.17.1",
"browserify": "^14.1.0",
"ejs": "^2.5.6",
"express": "^4.15.2",
"jquery": "^3.2.1",
"path": "^0.12.7",
"superagent": "^3.5.2"
},
"devDependencies": {},
"engines": {
"node": "6.8.1",
"npm": "4.0.5"
}
Solved! I had bundle.js included in my global gitinore configuration. Just had to take that out, good to go!
OK, I have an express app which is throwing this error at launch when deployed to Heroku. The app compiles and runs fine locally:
Cannot find module 'mongodb'
This app was running until I redeployed it yesterday ... here is my package.json which was unchanged
{
"name": "fitness-tracker",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"express": "~4.9.0",
"body-parser": "~1.8.1",
"cookie-parser": "~1.3.3",
"promise": "~6.0.1",
"morgan": "~1.3.0",
"serve-favicon": "~2.1.3",
"debug": "~2.0.0",
"mongodb-core": "*",
"mongoskin": "~2.0.0",
"express-handlebars": "~1.1.0",
"moment": "~2.0.0",
"moment-timezone": "^0.3.1",
"q": "~1.0.1",
"compass": "~0.1.0",
"apm": "*"
},
"devDependencies": {
"moment-timezone": "^0.3.1"
}
Ideas?
So the issue was package's resolution based on node version. Since NodeJS is rapidly evolving, it's a good practice to include engines specification in your package.json.
When doing automatic deployments on various cloud providers, this helps them to use only specified node & npm version. This was all the packages that get fetches are built for that node version hence less chances of app to misbehave.
Read more: https://docs.npmjs.com/files/package.json#engines
Also always worth a try: disable the Heroku build cache to recreate the node_modules directory.
In the Heroku CLI write:
$ heroku config:set NODE_MODULES_CACHE=false
$ git commit -am 'disable node_modules cache' --allow-empty
$ git push heroku master
As described here.
I'm deploying my node app to Heroku and it's trying to invoke it with nodemon rather than the node app.js I have defined. My Procfile looks like this:
web: npm start
And when I push to heroku the dyno crashes with this error:
2014-03-24T19:24:59.669412+00:00 app[web.1]: > my-app#0.0.1 start /app
2014-03-24T19:24:59.669412+00:00 app[web.1]: > nodemon app.js
2014-03-24T19:24:59.669412+00:00 app[web.1]:
2014-03-24T19:24:59.669412+00:00 app[web.1]:
2014-03-24T19:24:59.710228+00:00 app[web.1]:
2014-03-24T19:24:59.701246+00:00 app[web.1]: sh: nodemon: not found
I even tried npm installing nodemon as a package.json dependency, and checking in node_modules/nodemon but no luck. (nodemon needs to be installed with npm install nodemon -g for that to work anyway)
Any ideas?
My package.json:
{
"name": "my-app",
"version": "0.0.1",
"private": true,
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"dependencies": {
"requirejs": "~2.1.10",
"underscore": "~1.5.2",
"express": "~3.4.8",
"ejs": "~0.8.5",
"less-middleware": "~0.1.15",
"socket.io": "~0.9.16",
"tail": "~0.3.5",
"async": "~0.2.10",
"mongoose": "~3.8.5",
"mkdirp": "~0.3.5",
"ejs-locals": "~1.0.2",
"aws-sdk": "~2.0.0-rc8",
"knox": "~0.8.8",
"connect-multiparty": "~1.0.3",
"uuid": "~1.4.1",
"nodemon": "~1.0.14"
},
"devDependencies": {
"grunt": "~0.4.2",
"grunt-contrib-clean": "~0.5.0",
"grunt-contrib-copy": "~0.4.1",
"grunt-contrib-requirejs": "~0.4.1",
"grunt-recess": "~0.5.0",
"grunt-contrib-cssmin": "~0.7.0",
"grunt-mocha-test": "~0.9.0",
"grunt-forever": "~0.4.1",
"matchdep": "~0.3.0",
"jshint": "~2.4.3",
"precommit-hook": "~0.3.10",
"mocha": "~1.17.1",
"supertest": "~0.9.0",
"chai": "~1.9.0",
"sinon": "~1.8.2",
"karma-sinon": "~1.0.2",
"karma-script-launcher": "~0.1.0",
"karma-chrome-launcher": "~0.1.2",
"karma-firefox-launcher": "~0.1.3",
"karma-requirejs": "~0.2.1",
"karma-html2js-preprocessor": "~0.1.0",
"karma-jasmine": "~0.1.5",
"karma-coffee-preprocessor": "~0.1.3",
"karma-phantomjs-launcher": "~0.1.2",
"karma": "~0.10.9",
"karma-mocha": "~0.1.1",
"grunt-karma": "~0.6.2",
"karma-chai": "~0.1.0"
},
"config": {
"precommit": {
"lint": true
}
},
"engines": {
"node": "0.10.x"
}
}
Update
Sorry to have left everyone hanging all this time! If I remember correctly my issue in the end was my buildpack which was overriding the web: role in my Procfile.
I've since switched to different buildpacks, namely:
ddollar/heroku-buildpack-multi
With the following .buildpacks file:
ryandotsmith/nginx-buildpack
heroku/heroku-buildpack-nodejs
And my Procfile looks like this:
web: bin/start-nginx ./node_modules/.bin/forever --minUptime 10000 --spinSleepTime 1000 app.js
Change your Procfile to this:
web: node app.js
Being app.js the entry point to your app.
This is assuming you don't really need nodemon in your app, since you have listed it at the package.json sample you provided.
Recently I'm working on deployed my node js appication in heroku by using nodemon, for it's working fine.
we have to follow few step to reslove nodemon is not found.
1)Package.json
npm start: nodemon server.js
2)We need to modified procfile like below.
web: nodemon server.js
3)Use below command line to login for heroku
$ heroku login
4)Create new application
$heroku create <appication-name>
I think most of the developer directly deployed to heroku through github Id. Locally node_modules are work fine ,after deployed your application in heroku (inside we are n't able to access the node_modules), so for that we have access the respository.
5)Clone the repository from heroku
$ heroku git:clone -a <application-name>
$ cd cv-application
Now we are able access the application.
6)Delete you node_modules and try to install package by using below command.
$ npm install.
Deploy your changes.
$ git add .
$ git commit -am "make it better"
$ git push heroku master.
npm version sholud be 6.4.1.
I know that OP got the answer but I thought I might share what worked for me, in a slightly different senario:
Procfile contains the following:
web: npm start
And for my package.json file I defined:
"scripts":{
"start": "node ./bin/www"
}
And that fixed this issue for me.
Include nodemon as dev dependencies not as dependencies.
using this command remove nodemon.
npm uninstall nodemon
now install nodemon
npm install -D nodemon
In production or in deployment you shouldn't be using nodemon.