help icon indicating copy to clipboard operation
help copied to clipboard

internal/modules/cjs/loader.js:983 throw err; ^ Could you help me with this code?

Open duol45 opened this issue 4 years ago • 91 comments

internal/modules/cjs/loader.js:983 throw err; ^

Error: Cannot find module 'D:\Bryan Durán\Desktop\chat-javascript-fullstack-master\index.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)

at Function.Module._load (internal/modules/cjs/loader.js:862:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74

:12) at internal/main/run_main_module.js:18:47 { code: 'MODULE_NOT_FOUND', requireStack: []

duol45 avatar Apr 24 '20 08:04 duol45

Hello, can you give more information?

Romitou avatar Apr 24 '20 09:04 Romitou

I also get the same error on running cd ios && pod install && cd ../ && react-native run-ios

Trying to get the react native up and running.

prasanthnrkrish avatar Apr 28 '20 01:04 prasanthnrkrish

Hello,

I'm having the same problem as stated above. When type {node index.js } I get the error below, I tried number of solutions ie uninstalled node and npm then reinstalled then back separately. I'm still getting the same error, help needed.

The error:

interactive-SVG-image git:(master) ✗ node index.js
internal/modules/cjs/loader.js:983
 throw err;
 ^

Error: Cannot find module '/Users/lish/code/JavaScript_projects/interactive-SVG-image/index.js'
   at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
   at Function.Module._load (internal/modules/cjs/loader.js:862:27)
   at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
   at internal/main/run_main_module.js:18:47 {
 code: 'MODULE_NOT_FOUND',
 requireStack: []
}

lish90 avatar May 13 '20 09:05 lish90

delete node module and install again

shubhMjain avatar May 14 '20 11:05 shubhMjain

same errors:

...

> [email protected] postinstall /***/node_modules/core-js-pure
> node -e "try{require('./postinstall')}catch(e){}"


> [email protected] postinstall /***/node_modules/ejs
> node ./postinstall.js

internal/modules/cjs/loader.js:969
  throw err;
  ^

Error: Cannot find module '/***/node_modules/ejs/postinstall.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.Module._load (internal/modules/cjs/loader.js:842: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: []

Tried many ways:

  • rm -rf node_modules
  • rm -f package-lock.jso
  • npm cache clean --force
  • reinstall nodejs
  • ...

junhwong avatar Jun 24 '20 21:06 junhwong

versions: npm: '6.14.5', ares: '1.16.0', brotli: '1.0.7', cldr: '37.0', http_parser: '2.9.3', icu: '67.1', llhttp: '2.0.4', modules: '72', napi: '6', nghttp2: '1.41.0', node: '12.18.1', openssl: '1.1.1g', tz: '2019c', unicode: '13.0', uv: '1.38.0', v8: '7.8.279.23-node.38', zlib: '1.2.11'

junhwong avatar Jun 24 '20 21:06 junhwong

Work for me: If you are trying to work with node (backend) & react native (fronted) try:

         1.  Create new main folder (mkdir rootProjectName)
         2. from ProjectName/backend > init the node side (npm init --yes )
         3. from ProjectName/> init the react side ( react-native init fronted )

:)

Tetr0 avatar Jul 04 '20 04:07 Tetr0

Hello,

I'm having the same problem as stated above. When type {node index.js } I get the error below, I tried number of solutions ie uninstalled node and npm then reinstalled then back separately. I'm still getting the same error, help needed.

The error:

interactive-SVG-image git:(master) ✗ node index.js
internal/modules/cjs/loader.js:983
 throw err;
 ^

Error: Cannot find module '/Users/lish/code/JavaScript_projects/interactive-SVG-image/index.js'
   at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
   at Function.Module._load (internal/modules/cjs/loader.js:862:27)
   at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
   at internal/main/run_main_module.js:18:47 {
 code: 'MODULE_NOT_FOUND',
 requireStack: []
}

I do have the same issue .I tried many solutions ,I am feeling frustrated to solve this 🤣

shilpaanthati6 avatar Jul 11 '20 10:07 shilpaanthati6

Example index.js as module:


var productList = [{name: "banana"},{name: "apple"} ];

module.exports = { productList };


Tetr0 avatar Jul 13 '20 12:07 Tetr0

hhhhhhhhhhhhhhhhhhhhhhhhhre **Same Error! help**

micstudent avatar Jul 26 '20 13:07 micstudent

Hello, I'm having the same problem as stated above. When type {node index.js } I get the error below, I tried number of solutions ie uninstalled node and npm then reinstalled then back separately. I'm still getting the same error, help needed. The error:

interactive-SVG-image git:(master) ✗ node index.js
internal/modules/cjs/loader.js:983
 throw err;
 ^

Error: Cannot find module '/Users/lish/code/JavaScript_projects/interactive-SVG-image/index.js'
   at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
   at Function.Module._load (internal/modules/cjs/loader.js:862:27)
   at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
   at internal/main/run_main_module.js:18:47 {
 code: 'MODULE_NOT_FOUND',
 requireStack: []
}

I do have the same issue .I tried many solutions ,I am feeling frustrated to solve this 🤣

yes i Fix it

  1. npm cache clean --force

  2. delete node_modules folder

  3. delete package-lock.json file

  4. npm install

micstudent avatar Jul 26 '20 14:07 micstudent

I am struggling with this same issue. I followed the fix as well and it is not working for me. I am on windows 10 if that makes any difference. It seems to not be downloading the complete fileset of Node. Any help would be amazing.

adogam avatar Jul 28 '20 00:07 adogam

same issue, tried all of the solutions mentioned above, but no use. `` C:\Users\vinod\server>npm start

[email protected] start C:\Users\vinod\server nodemon expGqlServer.js

[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 expGqlServer.js internal/modules/cjs/loader.js:968 throw err; ^

Error: Cannot find module '../../temp' Require stack:

  • C:\Users\vinod\server\resolvers\post.js
  • C:\Users\vinod\server\node_modules@graphql-toolkit\file-loading\index.cjs.js
  • C:\Users\vinod\server\node_modules\merge-graphql-schemas\index.cjs.js
  • C:\Users\vinod\server\expGqlServer.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. (C:\Users\vinod\server\resolvers\post.js:2:14) 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 Module.require (internal/modules/cjs/loader.js:1025:19) { code: 'MODULE_NOT_FOUND', requireStack: [ 'C:\Users\vinod\server\resolvers\post.js', 'C:\Users\vinod\server\node_modules\@graphql-toolkit\file-loading\index.cjs.js', 'C:\Users\vinod\server\node_modules\merge-graphql-schemas\index.cjs.js', 'C:\Users\vinod\server\expGqlServer.js' ] } [nodemon] app crashed - waiting for file changes before starting... ``

vinodkv007 avatar Aug 08 '20 21:08 vinodkv007

same issue, tried all of the solutions mentioned above, but no use. `` C:\Users\vinod\server>npm start

[email protected] start C:\Users\vinod\server nodemon expGqlServer.js

[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 expGqlServer.js internal/modules/cjs/loader.js:968 throw err; ^

Error: Cannot find module '../../temp' Require stack:

  • C:\Users\vinod\server\resolvers\post.js
  • C:\Users\vinod\server\node_modules@graphql-toolkit\file-loading\index.cjs.js
  • C:\Users\vinod\server\node_modules\merge-graphql-schemas\index.cjs.js
  • C:\Users\vinod\server\expGqlServer.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. (C:\Users\vinod\server\resolvers\post.js:2:14) 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 Module.require (internal/modules/cjs/loader.js:1025:19) { code: 'MODULE_NOT_FOUND', requireStack: [ 'C:\Users\vinod\server\resolvers\post.js', 'C:\Users\vinod\server\node_modules@graphql-toolkit\file-loading\index.cjs.js', 'C:\Users\vinod\server\node_modules\merge-graphql-schemas\index.cjs.js', 'C:\Users\vinod\server\expGqlServer.js' ] } [nodemon] app crashed - waiting for file changes before starting... ``

I fixed the issue by using and trying different versions of node. It took a while to find the right one but I eventually did.

adogam avatar Aug 08 '20 23:08 adogam

I fixed the issue, apparently whenever you change your project directory some node modules will be imported automatically by node.js and along with it, some file paths inside the project will be changed. In my case when I moved my project to a different folder, ../temp was changed to, ../../temp I deleted the ../ and now it's working fine.

vinodkv007 avatar Aug 09 '20 21:08 vinodkv007

Where did you find the temp file?

mrrobotja avatar Aug 11 '20 08:08 mrrobotja

node js can only run app.js like you execute main function in other programming languages!

yonas1104 avatar Aug 18 '20 05:08 yonas1104

Thanks guys, this blog helped me so much to solve my problem with node!

freddyarh avatar Aug 22 '20 14:08 freddyarh

To anyone who stumbled upon this issue. All the above haven't worked for me, while deleting all the whitespaces from the path worked perfectly. As i see, topicstarter also has a whitespace in the path. This might've been the issue.

sefrem avatar Aug 26 '20 08:08 sefrem

First, check the path of your current folder under terminal else you will just run this command line :

rm -rf node_modules package-lock.json && npm install && npm start

maherbenissa avatar Sep 10 '20 09:09 maherbenissa

Am also facing the same issue... here is the solution from my end. if index.js not in our root folder means, we will getting error, once you move to root folder then server will be running

allocious avatar Sep 11 '20 18:09 allocious

Am also facing the same issue... here is the solution from my end. if index.js not in our root folder means, we will getting error, once you move to root folder then server will be running

Worked for me.

naimur978 avatar Sep 11 '20 18:09 naimur978

I too got faced the same issue . I got rid that finally by removing node modules that got installed twice and twice.

On Sat, Sep 12, 2020 at 12:08 AM Naimur Rahman [email protected] wrote:

Am also facing the same issue... here is the solution from my end. if index.js not in our root folder means, we will getting error, once you move to root folder then server will be running

Worked for me.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nodejs/help/issues/2644#issuecomment-691252336, or unsubscribe https://github.com/notifications/unsubscribe-auth/APY4QRXSA3CUOMDUQPWGBEDSFJVDVANCNFSM4MP5B33A .

shilpaanthati6 avatar Sep 12 '20 11:09 shilpaanthati6

I got faced the same issue and I solved it finally. In my case I was performing git push heroku main which also main isn't the default branch. I had to go to master branch first(default branch), merge the code with my other branch and then heroku git:remote -a <repoName> and git push heroku master.

HOPE this can help!

barhouum7 avatar Sep 19 '20 01:09 barhouum7

Oh my god!! i was struggling on this, tried everything, in the end, found out my file name was sever.js

abhiraizada avatar Sep 19 '20 18:09 abhiraizada

@duol45 - is there anything pending in this issue?

PoojaDurgad avatar Oct 05 '20 16:10 PoojaDurgad

If someone still stuck, leave a comment.

deepakyadav2254 avatar Oct 06 '20 19:10 deepakyadav2254

2020-10-13T04:57:12.561758+00:00 app[Worker.1]: internal/modules/cjs/loader.js:883 2020-10-13T04:57:12.561775+00:00 app[Worker.1]: throw err; 2020-10-13T04:57:12.561775+00:00 app[Worker.1]: ^ 2020-10-13T04:57:12.561776+00:00 app[Worker.1]: 2020-10-13T04:57:12.561776+00:00 app[Worker.1]: Error: Cannot find module './config.json' 2020-10-13T04:57:12.561776+00:00 app[Worker.1]: Require stack: 2020-10-13T04:57:12.561777+00:00 app[Worker.1]: - /app/index.js 2020-10-13T04:57:12.561778+00:00 app[Worker.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15) 2020-10-13T04:57:12.561778+00:00 app[Worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:725:27) 2020-10-13T04:57:12.561778+00:00 app[Worker.1]: at Module.require (internal/modules/cjs/loader.js:952:19) 2020-10-13T04:57:12.561779+00:00 app[Worker.1]: at require (internal/modules/cjs/helpers.js:88:18) 2020-10-13T04:57:12.561779+00:00 app[Worker.1]: at Object. (/app/index.js:7:20) 2020-10-13T04:57:12.561780+00:00 app[Worker.1]: at Module._compile (internal/modules/cjs/loader.js:1063:30) 2020-10-13T04:57:12.561780+00:00 app[Worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10) 2020-10-13T04:57:12.561780+00:00 app[Worker.1]: at Module.load (internal/modules/cjs/loader.js:928:32) 2020-10-13T04:57:12.561781+00:00 app[Worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:769:14) 2020-10-13T04:57:12.561781+00:00 app[Worker.1]: at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12) { 2020-10-13T04:57:12.561782+00:00 app[Worker.1]: code: 'MODULE_NOT_FOUND', 2020-10-13T04:57:12.561782+00:00 app[Worker.1]: requireStack: [ '/app/index.js' ] 2020-10-13T04:57:12.561783+00:00 app[Worker.1]: }

MOSMOSterTVZall avatar Oct 13 '20 04:10 MOSMOSterTVZall

@MOSMOSterTVZall - can you elaborate your issue more please? which command you are trying to run ? for me by looking at the error log your issue looks like there is a missing config.json in your current working path. make sure it is configured properly and if that is not the case try to add explicitly to the package.json hope it may help.

PoojaDurgad avatar Oct 13 '20 13:10 PoojaDurgad

Hello, I'm having the same problem as stated above. When type {node index.js } I get the error below, I tried number of solutions ie uninstalled node and npm then reinstalled then back separately. I'm still getting the same error, help needed. The error:

interactive-SVG-image git:(master) ✗ node index.js
internal/modules/cjs/loader.js:983
 throw err;
 ^

Error: Cannot find module '/Users/lish/code/JavaScript_projects/interactive-SVG-image/index.js'
   at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
   at Function.Module._load (internal/modules/cjs/loader.js:862:27)
   at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
   at internal/main/run_main_module.js:18:47 {
 code: 'MODULE_NOT_FOUND',
 requireStack: []
}

I do have the same issue .I tried many solutions ,I am feeling frustrated to solve this 🤣

yes i Fix it

  1. npm cache clean --force
  2. delete node_modules folder

  3. delete package-lock.json file

  4. npm install

Worked for me thanks

varunreddy305 avatar Oct 28 '20 14:10 varunreddy305