I am trying to run an express app that I installed using express --view pug urltracker. I also executed npm install to install all dependencies.
When I start it on my laptop localhost using DEBUG=urltracker:* && npm start
it perfectly starts on localhost:3000 and my app runs smoothly but when I install it on centos 7 server, the same gets stuck at [nodemon] starting `node ./bin/www and nothing happens afterwards.
I tried running it like this as well DEBUG=backend ./bin/www but it says -bash: ./bin/www: Permission denied OR sudo: ./bin/www: command not found
I can execute a normal file like node app.js and it works fine but when it comes to running it as server, it doesn't work.
Here's my package.json
{
"name": "urltracker",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "nodemon ./bin/www"
},
"dependencies": {
"body-parser": "~1.18.2",
"cookie-parser": "~1.4.3",
"debug": "~2.6.9",
"express": "~4.15.5",
"morgan": "~1.9.0",
"pug": "2.0.0-beta11",
"serve-favicon": "~2.4.5",
"puppeteer": "^1.6.2",
"puppeteer-select": "^1.0.3"
},
"devDependencies": {
"eslint-plugin-mocha": "^4.11.0",
"file-system": "^2.2.2",
"jest": "^21.2.1",
"js-comments": "^0.5.4",
"lodash": "^4.17.13"
}
}
I also tried it with running node supervisor using supervisor ./bin/www
but it says
Starting child process with 'node ./bin/www'
Watching directory '/home/admin/web/example.com/node/projects' for changes.
Press rs for restarting the process.
I also tried changing the port to 3001 in ./bin/www like this - server.listen('3001', '0.0.0.0');
but nothing works. Help.
Nodemon is not listed in your dependencies list in package.json and on the centos server nodemon is not present.
Please add the nodemon dependency in the package.json and then run npm i
or change the start script from "start": "nodemon ./bin/www" to "start": "node ./bin/www"
Related
I’m following a tutorial https://mindthecode.com/using-vue-components-in-your-express-app/ to use vue components with Express.
Part of that is configuring an npm dev script to compile the vue component with Browserify/vueify, start Watchify, then start the Express Server.
Every step of the turorial worked but the ‘dev’ script doesn't work 100% as the express server doesn't start.
Can anyone help figure how what is wrong or what I need to do to get that script working?
Package.json
"scripts": {
"start": "echo 'server starting on port 3000' & node ./bin/www",
"dev": "watchify -vd -p browserify-hmr -t vueify -e public/javascripts/main.js -o public/javascripts/bundle.js & node ./bin/www"
},
‘npm run dev’ compiles the vue component and starts watchify and the hot reload works if I change the vue component code. HOWEVER, the express server fails to start?
Note:
browserify -t vueify -e public/javascripts/main.js -o public/javascripts/bundle.js – works fine at the command line to compile the .vue files
npm start – works fine and can load page at ‘localhost:3000’
I'm using windows10, node v8.9.4 and some of the relevant dependencies from package.json
"browserify-hmr": "^0.3.5",
"express": "~4.14.0",
"vue": "^2.5.0",
"vueify": "^9.4.1",
"watchify": "^3.9.0"
You can see completed package.json and full repo from this tutorial
https://github.com/Hyra/vue-components-in-express/blob/master/package.json
{
"name": "vue-components-in-express",
"version": "0.0.1",
"private": false,
"description": "Sample code to support blog post 'Using Vue Components in your Express app' at https://mindthecode.com/using-vue-components-in-your-express-app/",
"author": "Stef van den Ham <stef#mindthecode.com>",
"scripts": {
"start": "node ./bin/www",
"dev": "watchify -vd -p browserify-hmr -t vueify -e public/javascripts/main.js -o public/javascripts/bundle.js & node ./bin/www"
},
"dependencies": {
"body-parser": "~1.15.2",
"browserify-hmr": "^0.3.5",
"cookie-parser": "~1.4.3",
"debug": "~2.2.0",
"express": "~4.14.0",
"morgan": "~1.7.0",
"node-sass": "^4.5.3",
"pug": "~2.0.0-beta6",
"serve-favicon": "~2.3.0",
"vue": "^2.5.0",
"vueify": "^9.4.1",
"watchify": "^3.9.0"
}
}
I'm trying to run a node.js app on heroku, it runs fine using npm start and using heroku locally, but does not run when hosted on heroku. I have looked through all the solutions i could find, the remote mongodb database works fine when run using npm start, my port is set up correctly, have restarted heroku and dynamos a bunch of times, and I have a procfile with the following:
web node index.js
The following is the console messages I get:
Starting process with command `node index.js`
Warning: connect.session() MemoryStore is not
designed for a production environment, as it will leak
memory, and will not scale past a single process.
Application ready to serve requests.
Environment: production
app[web.1]: (node:4) DeprecationWarning: `open()` is deprecated in
mongoose >= 4.11.0,
use `openUri()` instead, or set the `useMongoClient` option if using
`connect()`
or `createConnection()`. See
http://mongoosejs.com/docs/connections.html#use-mongo-client
Db.prototype.authenticate method will no longer be available in the
next major
release 3.x as MongoDB 3.6 will only allow auth against users in the
admin db
and will no longer allow multiple credentials on a socket. Please
authenticate using MongoClient.connect with auth credentials.
DB Connection Open...
Error R10 (Boot timeout) -> Web process failed to bind to $PORT within
60 seconds of launch
Stopping process with SIGKILL
Process exited with status 137
This is my package.json:
{
"name": "shop",
"version": "0.1.0",
"description": "eCommerce Site",
"author": "Slav Bugryn",
"main": "index.js",
"scripts": {
"test": "grunt test",
"build": "grunt build",
"all": "npm run build && npm run test",
"start": "node server.js"
},
"dependencies": {
"connect-flash": "^0.1.1",
"construx": "^1.0.0",
"construx-copier": "^1.0.0",
"construx-dustjs": "^1.1.0",
"construx-less": "^1.0.0",
"dust-makara-helpers": "^4.2.0",
"dustjs-helpers": "^1.7.3",
"eslint": "^4.12.1",
"express": "^4.12.2",
"express-messages": "^1.0.1",
"kraken-js": "^2.0.0",
"makara": "^2.0.3",
"mongodb": "^2.2.33",
"mongoose": "^4.13.6",
"requirejs": "^2.3.5"
},
"devDependencies": {
"grunt": "^1.0.1",
"grunt-cli": "^1.2.0",
"grunt-config-dir": "^0.3.2",
"grunt-contrib-clean": "^1.1.0",
"grunt-contrib-less": "^1.4.1",
"grunt-contrib-requirejs": "^1.0.0",
"grunt-copy-to": "0.0.12",
"grunt-dustjs": "^1.4.0",
"grunt-eslint": "^20.1.0",
"grunt-makara-amdify": "^1.0.1",
"grunt-mocha-cli": "^3.0.0",
"mocha": "^4.0.1",
"supertest": "^3.0.0"
},
"directories": {
"lib": "lib",
"test": "test"
},
"keywords": [],
"license": "ISC"
}
Any advice would be greatly appreciated, thanks in advance.
Figured it out! I sent the Procfile to the wrong place (had to go to server.js, which i found out by looking in package.json and finds start under scripts), after fixing that I got another error (same as here, where i also got the fix: Got a internal server error after I deploy my node js project to the host) which i fixed by running grunt build (had to use --force too).
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!
There must have some simple solution with this problem. I have created a new project using Webstorm for Express js + Node js. Then i installed nodemon using npm install -g nodemon and it was fine. But when i am trying to start my app using nodemon app.js it is showing only
sany2k8#sany2k8-Aspire-4752:/var/projects/ENStack$ nodemon app.js
[nodemon] 1.9.2
[nodemon] to restart at any time, enter rs [nodemon] watching: .
[nodemon] starting node app.js
[nodemon] clean exit - waiting for changes before restart
package.json
{
"name": "ENStack",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "node ./bin/www"
},
"dependencies": {
"body-parser": "~1.13.2",
"cookie-parser": "~1.3.5",
"debug": "~2.2.0",
"express": "~4.13.1",
"jade": "~1.11.0",
"morgan": "~1.6.1",
"serve-favicon": "~2.3.0"
}
}
Edit: When i tried with npm start then it is showing bunch of errors
sany2k8#sany2k8-Aspire-4752:/var/projects/ENStack$ npm start
ENStack#0.0.0 start /var/projects/ENStack
node ./bin/www
Port 3000 is already in use
we need to add start with nodemon ./bin/www in the json file and
run your project using: nodemon app
{
"name": "ENStack",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "nodemon ./bin/www"
},
"dependencies": {
"body-parser": "~1.13.2",
"cookie-parser": "~1.3.5",
"debug": "~2.2.0",
"express": "~4.13.1",
"jade": "~1.11.0",
"morgan": "~1.6.1",
"serve-favicon": "~2.3.0"
}
}
Additionally, some times, the port are in use. If the solution above not work for you, try change the port. It may be in use for some other node instance.
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.