I'm trying to start my app but every time I try npm run dev I get an error:
internal/modules/cjs/loader.js:905
throw err;
^
Error: Cannot find module 'C:\Users\myname\Desktop\mern\index.js'
code: 'MODULE_NOT_FOUND',
requireStack: []
I don't remember this ever happening in the past so I'm at a lost for words. I tried deleting node_modules / package.json & re-installing them but that didn't work. Here is my code:
package.json:
{
"name": "mern",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node src/index.js",
"dev": "nodemon src/index.js"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"nodemon": "^2.0.13"
}
}
I think the problem has to be here in the package.json file but this is how i've always written it so I'm not sure what to do. Some help will be appreciated.
I figured it out. I had both the src and index.js in a server file. In the package.json file I both the src/index.js to server/src/index.js