how to solve it: internal/modules/cjs/loader.js:883 - node.js

Hi I have an error trying to run yarn dev (node ./index.js)
any ideas to solve? maybe I need to install something?
my package.json is but I don't know why it doesn't execute
{
"name": "instaclone",
"version": "1.0.0",
"description": "The Instaclone app server",
"main": "index.js",
"author": "Cesaru",
"license": "MIT",
"scripts": {
"dev": "node ./index.js"
},
"dependencies": {
"apollo-server": "^ 2.19.0",
"dotenv": "^ 8.2.0",
"graphql": "^ 15.4.0",
"mongoose": "^ 5.11.3"
}
}

try removing node_modules folder and run yarn install again

Related

error Couldn't find the binary nodemon index.js error in node.js

I am a beginner in node-js and I have been learning it using this this video. I have installed the nodemon package and referenced it in package.json. the issue is when I try to start the app in the index.js I get this
.this is my package.json
{
"name": "hotelmgtandrsrvreactandnodejs",
"version": "1.0.0",
"description": "",
"main": "index.js",
"type": "module",
"scripts": {
"start": "nodemon index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.18.2",
"nodemon": "^2.0.20"
}
}

When typing yarn start in the terminal an error occurs stating /bin/sh: nodemon: command not found Command failed with exit code 127 comes up

My json package is below
{
"name": "node-rest-api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "nodemon index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.3",
"mongoose": "^6.2.3"
}
}
I have exhausted all solutions I have found as most of them point to me having start in my json package which I already do so,
Because nodemon module is not installed
either install manually by below command
npm i nodemon
or add nodemon in pakage.json
{
"name": "node-rest-api",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "nodemon index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.3",
"mongoose": "^6.2.3",
}
"devDependencies": {
"nodemon" : "^2.0.15"
}
}
and after that npm install

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?

Node | TypeScript Error : ts-node-dev --rs (restart) option

I am using the --rs option (--rs - Allow to restart with "rs" line entered in stdio, disabled by default)
This is giving me error while running npm run publish :
The package.json file :
{
"name": "nats-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"publish": "ts-node-dev --rs --notify false src/publisher.ts",
"listen": "ts-node-dev --rs --notify false src/listener.ts"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#types/node": "^14.0.23",
"node-nats-streaming": "^0.3.2",
"ts-node-dev": "^1.0.0-pre.51",
"typescript": "^3.9.6"
}
}
Would really appreciate the help.
Try adding the --rs flag to the ts-node-dev command:
ts-node-dev --rs src/publisher.ts

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