I also had a similar issue with the last project I created
I have tried what was recommended here internal/modules/cjs/loader.js:582 throw err, although cannot guarantee that I did it right.
I have also tried creating an index.js file. Moving the index.js file and changing the "main" in package.json to various things.
I will include a picture so that you can see the file structure. Please help:
Error Message
internal/modules/cjs/loader.js:968
throw err;
^
Error: Cannot find module './mail'
Require stack:
- /Users/test/Desktop/Git/Deep Technology/Deep-Technology/server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/test/Desktop/Git/Deep Technology/Deep-Technology/server.js:5:18)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/test/Desktop/Git/Deep Technology/Deep-Technology/server.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Deep-Technology@1.0.0 start: `node server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Deep-Technology@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/test/.npm/_logs/2020-08-16T20_38_06_132Z-debug.log
Andrews-iMac:Deep-Technology test$
Andrews-iMac:Deep-Technology test$ node run start
internal/modules/cjs/loader.js:968
throw err;
^
Error: Cannot find module '/Users/test/Desktop/Git/Deep Technology/Deep-Technology/run'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Andrews-iMac:Deep-Technology test$ node server
internal/modules/cjs/loader.js:968
throw err;
^
Error: Cannot find module './mail'
Require stack:
- /Users/test/Desktop/Git/Deep Technology/Deep-Technology/server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/test/Desktop/Git/Deep Technology/Deep-Technology/server.js:5:18)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/test/Desktop/Git/Deep Technology/Deep-Technology/server.js'
]
}
Andrews-iMac:Deep-Technology test$ nodemon start
[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node start index.js`
[nodemon] clean exit - waiting for changes before restart
^CAndrews-iMac:Deep-Technology test$
Update
Some errors were resolved, but still this node error:
node server
internal/modules/cjs/loader.js:968
throw err;
^
Error: Cannot find module './node_modules/dotenv/types'
Require stack:
- /Users/test/Desktop/Git/Deep Technology/deep-technology/server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/test/Desktop/Git/Deep Technology/deep-technology/server.js:2:1)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/test/Desktop/Git/Deep Technology/deep-technology/server.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! deep-technology@1.0.0 start: `node server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the deep-technology@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/test/.npm/_logs/2020-08-16T21_23_44_657Z-debug.log
Andrews-iMac:Deep-Technology test$
Update, this is a completely different project, and I have exactly the same error code (968), It seems that I am consistently doing something wrong, code and file structure picture and error log below
> node server.js
internal/modules/cjs/loader.js:968
throw err;
^
Error: Cannot find module '/Users/test/Desktop/Git/Project IA/Project-IA/server.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myinfuenceradssite@1.0.0 start: `node server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myinfuenceradssite@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/test/.npm/_logs/2020-08-22T13_03_32_052Z-debug.log
Andrews-iMac:public test$