内部/模块/cjs/loader.js:582抛出错误 [英] internal/modules/cjs/loader.js:582 throw err

查看:1106
本文介绍了内部/模块/cjs/loader.js:582抛出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注控制台错误. Error : Cannot find module

I'm getting following Console Error. Error : Cannot find module

这是我进入控制台的完整错误.我该怎么办?

Here is the full error i'm getting in console. What should I 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)

推荐答案

当我第一次尝试使用节点js时,我遇到了相同的问题.
我注意到此问题正在发生,因为我在不同的目录中有一些具有相同名称的.js文件,这些文件位于相同的主目录中.
我在主项目文件夹之外创建了另一个目录,并创建了一个.js文件.
之后,它运行良好.
前app.js

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

这篇关于内部/模块/cjs/loader.js:582抛出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆