why my npm start using nodemon gives me error?

28 views Asked by At

npm start using nodemon give me error which I not understand at all.

the way I understand it is I install the nodemon locally in the specific directory I working on. I install nodemon using the command "npm install --save-dev nodemon". Then, I add the script of start in the package.json which supposedly allow me to use the npm start command to use the nodemon modules in the shell. But turns out it gives me error of this: PS C:\Users\irfan_j5mtdic\Documents\study matter\bljr\24 - node.js & express.js pt 1\nodeJsLearn> npm start

[email protected] start npx nodemon

'express.js' is not recognized as an internal or external command, operable program or batch file. node:internal/modules/cjs/loader:1051 throw err; ^

Error: Cannot find module 'C:\Users\irfan_j5mtdic\Documents\study matter\bljr\nodemon\bin\nodemon.js' at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15) at Module._load (node:internal/modules/cjs/loader:901:27) at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12) at node:internal/main/run_main_module:23:47 { code: 'MODULE_NOT_FOUND', requireStack: [] }

Node.js v20.9.0

Turns out it refer to module outside of the directories that I installed nodemon which is does not exists. I also dont understand the part where express.js is not recognized as an internal of external command because I am not using any express.js here.

this is my package.json:

{
  "name": "nodejslearn",
  "version": "1.0.0",
  "type": "module",
  "main": "script.js",
  "scripts": {
    "start": "npx nodemon",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "description": "",
  "devDependencies": {
    "nodemon": "^3.1.0"
  }
}

this is my script.js:

import { largeNumber } from './script2.js'

const a = largeNumber;
const b = 5;
setTimeout(() => {
    console.log(a+b);
}, 3000)

this is my script2.js:

export const largeNumber = 3;
0

There are 0 answers