nodemon not working, Usage: nodemon [nodemon options] [script.js] [args] See "nodemon --help" for more [duplicate] - node.js

This question already has answers here:
nodemon not working properly
(19 answers)
Closed 7 months ago.
{
"name": "nodeserver",
"version": "1.0.0",
"description": "This is a node Server for LetsChat Application",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "neetu",
"license": "ISC",
"dependencies": {
"nodemon": "^2.0.4",
"socket.io": "^2.3.0"
}
}

First try to Install Nodemon as Global
npm install -g nodemon
As per your Package.json details, Run
nodemon index.js
If still you face issue, Try to add some details like Error Message you get running nodemon.

Related

Powershell throws error when running npm start / npx tsc

I am trying to run a simple npm start from the powershell command in a express - typescript project. And I'm getting this error
/mnt/host/c/Users/-/AppData/Roaming/npm/node: line 8: /mnt/host/c/Users/-/AppData/Roaming/npm/node_modules/nodemon/bin/nodemon.js: not found
My package.json
{
"name": "express-typescript",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node build/index.js",
"test": "echo "Error: no test specified" && exit 1"
},
"keywords": \[\],
"author": "",
"license": "ISC",
"devDependencies": {
"#types/express": "^4.17.14",
"typescript": "4.9.3"
},
"dependencies": {
"express": "4.18.2"
}
}
This is the node file config inside npm/node
\#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
case `uname` in
*CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
esac
"$basedir/node_modules/nodemon/bin/nodemon.js" "$#"
exit $?
The thing is with git bash I have no problems but powershell is my main editor. I tried reinstalling Node, closing everything, restarting.
I don't know why node is looking for nodemon and even if I install the dependency globally it doesn't work. Any suggestion?
Same thing happens if I try to run npx node, npx tsc, etc.

nodemon: not found on heroku

My app runs locally with no issues by its failing on Heroku
package.json
{
"name": "app name",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"start": "nodemon app.js"
},
"engines": {
"node": "14.17.0"
},
"author": "",
"license": "ISC",
"dependencies": {
"body-parser": "^1.19.0",
"express": "^4.17.1",
"mongoose": "^5.12.9"
}
}
Procfile
web:node app.js
its returning the below error
sh: 1: nodemon: not found
Any help on how to make this work?
The nodemon is installed globally on your machine that's why you are able to run it on your machine. When you are pushing it on Heroku it is showing the error because there is nothing like nodemon.
Also, Heroku doesn't need nodemon so just replace your start script:
node app.js
and change your Procfile to this:
web: npm start
Even I had the same issue.
You just have to remove nodemon from start script
It has to be iin this way;
"scripts": { "start": "src/index.js", "dev": "env-cmd -f ./config/dev.env nodemon src/index.js" }

sh: 1: cucumber.js: not found

Trying to use this tutorial here:
https://github.com/lykmapipo/nodejs-cucumber-sample
The output to nvm current is: v10.12.0.
The output to npm --version is: 6.4.1>
I get the error below once I invoke npm test:
> nodejs-cucumber-sample#0.0.1 test /home/gnuc/code/nodejs-cucumber-sample
> cucumber.js
sh: 1: cucumber.js: not found
I am not sure as to why this is the case. The $PATH includes /home/gnuc/.nvm/versions/node/v10.12.0/bin. And I have already used npm install cucumber -g and npm install cucumber
Make sure that your package.json file includes this: "test": "cucumber-js"
So that it looks something like this:
{
"name": "hellocucumber",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": **"cucumber-js"**
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"cucumber": "^5.1.0"
}
}
So, you need to actually call the npm package/library. I have the following defined in my package.json:
"scripts": {
"test": "node ./node_modules/.bin/cucumber-js"
},
you can also add some ---tags in this call.
"scripts": {
"test": "node ./node_modules/.bin/cucumber-js --tags #RegressionTestSuite"
},
this will run any feature files that have #RegressionTestSuite at the top
Also, I have an output/results file created with a time stamp.
"scripts": {
"test": "node ./node_modules/.bin/cucumber-js --tags #RegressionTestSuite --format json:./results/log_new_`date +%Y-%m-%m__%H-%M`.json""
},
I hope this helped.
node ./node_modules/cucumber/bin/cucumber-js
This command is working fine.
And you got sh:1: cucumber.js: not found error means first things please look out the path of cucumber.js

Heroku deployment fails with "missing script: start"

I am trying to upload my local MEAN stack based web application to my Heroku server. I have updated my code in Bitbucket and have successfully done the Heroku deployment part. But, the web app is still not live. When I hit the page, I am getting something like this:
I then checked the logs by firing 'heroku logs' but I am unable to understand what the logs are trying to ask for. I am sharing the logs below:
As I understand it, the application was unable to find "start" but I have later exclusively added "start" : "node app.js" but I still don't see any difference in the heroku logs or in the heroku link.
Can anyone help with what am I doing wrong here?
here's my package.json file
{
"start": "node app.js",
"name": "PerosnalPro",
"version": "1.0.0",
"description": "Personal website using dynamic routing and responsive design.",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Mikey",
"license": "ISC",
"dependencies": {
"dotenv": "^1.2.0",
"ejs": "^2.3.4",
"express": "^4.13.3",
"morgan": "^1.6.1",
"serve-favicon": "^2.3.0",
"slick-carousel": "^1.5.9"
},
"devDependencies": {},
"repository": {
"type": "git",
"url": "git+https://user#bitbucket.org/username/projectname"
},
"homepage": "https://bitbucket.org/username/projectname"
}
"scripts": {
"start" : "node app.js",
"test": "echo \"Error: no test specified \" && exit 1"
}
Add your start tag in scripts. :)

Why devDependencies is not installed

I developed a package for example: testlab, and its package.json is:
{
"devDependencies": {
"mocha": "^2.0.0"
},
"name": "#aab/testlab",
"version": "2.6.0",
"description": "example for npm",
"main": ".\\dest\\main.js",
"dependencies": {
"gulp": "^3.9.1",
"gulp-changed": "^1.3.2"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [
"test"
],
"author": "aab <aab#exmaple.com>",
"license": "ISC"
}
Say I included mocha in devDendencies, and then I created a local directory called e.g. c:\example and used
npm install #aab/testlab --only=dev
to get my package under c:\example, but when I looked at c:\example\node_modules, I did not find mocha package is installed. I also tried other command like
npm install #aab/testlab
still no luck. I used NodeJS v4.6.0 and npm 4.0.2. Although nodeJS seems a little old, could any one help me that?
I have seen this happen only when NODE_ENV is set to PRODUCTION. Something else might be setting it.

Resources