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?
Related
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": {}
}
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
I have a very basic index.js that has these imports like so:
import { MikroORM } from "#mikro-orm/core";
import { __prod__ } from "./constants";
import { Post } from "./entities/Post";
Here's my package.json:
{
"name": "reddit-server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"watch": "tsc -w",
"dev": "nodemon dist/index.js",
"start": "node dist/index.js",
"start2": "ts-node src/index.ts",
"dev2": "nodemon --exec ts-node src/index.ts",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"#types/node": "^16.3.2",
"nodemon": "^2.0.12",
"ts-node": "^10.1.0",
"typescript": "^4.3.5"
},
"dependencies": {
"#mikro-orm/cli": "^4.5.7",
"#mikro-orm/core": "^4.5.7",
"#mikro-orm/migrations": "^4.5.7",
"#mikro-orm/postgresql": "^4.5.7",
"pg": "^8.6.0"
}
}
I compile them with tsc into a dist directory with structure like:
[1]: https://i.stack.imgur.com/uC5pU.png
It gives me the error:
Cannot find module '/Users/kevinli/reddit-clone/reddit-server/dist/constants' imported from /Users/kevinli/reddit-clone/reddit-server/dist/index.js
I'm confused because they seem to be in the same directory and should be importing correctly?
If I try to remove "type": "module",, it tells me I cannot import something outside a module.
I faced the same issue today.
Try adding the extension .js or whatever it is to the import path.
I learnt without the extension nodejs assumes the path is a directory, so it will be expecting an index.js (default) file inside it.
{
"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?
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"
}
}