internal/modules/cjs/loader.js:582 throw err

2020-02-19 05:14发布

Recently I started learning Node.js with express. I have tried express router which threw an error. The bigger issue is what caused this and how can I avoid it again. This problem makes me worry and discourages me to learn node.js.

Here is the error. What do I need to do?

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

Error: Cannot find module 'C:\Users\User\Desktop\NodeJsProject\app.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
    at Function.Module._load (internal/modules/cjs/loader.js:506:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)
    at startup (internal/bootstrap/node.js:285:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:739:3)

12条回答
Summer. ? 凉城
2楼-- · 2020-02-19 05:37

The below commands resolved the issue for me.

npm install node-gyp -g
npm install bcrypt -g

npm install bcrypt -save
查看更多
三岁会撩人
3楼-- · 2020-02-19 05:40

Something weird happened to me last night. I ran command node run watch instead of npm run watch. I tried doing everything on this thread but nothing worked out for me. I was frustrated but eventually noticed that I ran the command wrong. I was laughing out loud. Sometimes this things happened. Enjoying learning Nodejs though.

查看更多
三岁会撩人
4楼-- · 2020-02-19 05:44

I had the same issue when I first tried on node js.
I noticed this issue was happening to me because I had some .js files with same names in different directories, which were in the same main directory.
I created another directory outside the main project folder, and created a .js file.
After that, it ran fine.
ex- app.js

查看更多
Rolldiameter
5楼-- · 2020-02-19 05:46

i was in the sub folder of the application and it was throwing that error. going to main directory of application resolved my issue.

查看更多
地球回转人心会变
6楼-- · 2020-02-19 05:47

same happen to me i just resolved by deleting "dist" file and re run the app.

查看更多
贪生不怕死
7楼-- · 2020-02-19 05:48

I uninstalled puppeteer, mocha and chai using

npm uninstall puppeteer mocha chai

from the command line and then reinstalled using

npm install puppeteer mocha chai

and the error message simply never showed up

查看更多
登录 后发表回答