server is not starting on save - nodemon - node.js

I am working on a graphql project. I have installed nodemon globally but whenever I make any change I have to restart manually because for some reason nodemon is not working correctly. Following is my environment
Ubuntu
Nodejs 10.24.1
nodemon 2.0.15
and my Package.json file is following
{
"name": "graphql-basic",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "nodemon --exec babel-node src/index.js",
"test": "echo \"Error: no test specified\" && exit 1",
"get-schema": "graphql get-schema -p prisma"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"babel-cli": "^6.26.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.7.0",
"graphql-cli": "^2.16.4",
"graphql-yoga": "^1.16.7",
"prisma-binding": "^2.1.1",
"uuid": "^3.3.2"
},
"devDependencies": {}
}

Related

Error: Cannot find module Please verify that the package.json has a valid "main" entry

i will delete the node modules file again reinstall npm i but my problem couldn't solve the problem
here's the code ok package.json
{
"name": "backend",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "nodemon server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"bcrypt": "^5.1.0",
"body-parser": "^1.20.1",
"cctx": "^1.0.1",
"dotenv": "^16.0.3",
"express": "npm:Express#^3.0.1",
"Express": "^3.0.1"
},
"devDependencies": {
"nodemon": "^2.0.20"
}
}

NodeJS App Crashing on Heroku Due To Unsupported Directory Imports

So I am simply trying to deploy my node server to Heroku cloud. It is crashing because of the ES modules not supported issue. The specific error I am getting is
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import '/app/src/routes' is not supported resolving ES modules imported from /app/src/server.js
I am trying to import my routes directory. I have read the solutions on Stack related to this issue, and none of them are working for me. For example inlcuding "type":"module" in my package.json, is NOT working.
What's going on? It runs perfectly locally using 'npm run dev' script.
Ironman
package.json
{
"name": "back-end",
"type": "module",
"version": "1.0.0",
"description": "",
"engines": {
"node": "14.x"
},
"main": "index.js",
"scripts": {
"dev": "nodemon --exec babel-node -r dotenv/config ./src/server.js",
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node -r dotenv/config ./src/server.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#babel/core": "7.13.10",
"#babel/node": "7.13.12",
"#babel/preset-env": "7.13.12",
"#sendgrid/mail": "^7.6.0",
"axios": "^0.24.0",
"bcrypt": "^5.0.1",
"dotenv": "^10.0.0",
"esm": "^3.2.25",
"express": "4.17.1",
"googleapis": "^92.0.0",
"jsonwebtoken": "^8.5.1",
"mongodb": "3.6.5",
"uuid": "^8.3.2"
},
"devDependencies": {
"nodemon": "2.0.7"
}
}
The answer, the solution, was to require the esm package on startup:
"start": "node -r esm -r dotenv/config ./src/server.js"

Getting error: "npm ERR! missing script: start", yet start script is there

{
"name": "oculus_scraper_node",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"cheerio": "^1.0.0-rc.5",
"nodemailer": "^6.4.17",
"puppeteer": "^5.5.0"
}
}
When using heroku and checking if it deployed properly, I keep getting an error reading "npm ERR! missing script: start", but i definitely have the start script in my program, as you can see. I've looked through a couple other posts but nothing has worked. Any ideas?

Getting error : when set debugger in Nightwatchjs

Hi everyone I want to set debugger in my Nightwatchjs project But I got one error
my package.json
{
"name": "intro-to-nightwatchjs",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"lint": "eslint .",
"debug": "node --inspect-brk node_modules/.bin/nightwatch",
"test": "nightwatch"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"chromedriver": "^80.0.1",
"eslint": "^6.8.0",
"minimist": "^1.2.5",
"nightwatch": "^1.3.4",
"optimist": "^0.6.1"
}
}

nodemon cannot recognize mocha

I tried to run test automatically using nodemon instead of running them manually. I installed mocha and nodemonn on single time. This is how my package.json looks like:
{
"name": "Ti Ri Ho",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "nodemon --exec 'mocha -R min'"
},
"author": "",
"license": "ISC",
"dependencies": {
"mocha": "^5.2.0",
"mongoose": "^5.3.15",
"nodemon": "^1.18.7"
}
}
I change "scripts": {"test": "mocha" } to "scripts": {"test": "nodemon --exec 'mocha -R min'"}.What could be the possible reason?

Resources