简体   繁体   English

找不到模块'./config'

[英]Cannot find module'./config'

Whenever I type node.每当我输入节点。 in terminal, (I'm using Visual Studio, idk if that matters) it gives me this error:在终端中,(我正在使用 Visual Studio,idk 如果重要的话)它给了我这个错误:

  throw err;
  ^

Error: Cannot find module './config'

For issues related to the terminal, try to install npm locally, it might solve the problem.对于终端相关的问题,尝试在本地安装npm,可能会解决问题。

(or) (或者)

You can make the directory root of your project, as explained in this link您可以创建项目的根目录,如此链接中所述

For issues related to compilation, you need a proper way to reference files relative to application root in Node.JS对于与编译相关的问题,您需要一种正确的方法来引用 Node.JS 中相对于应用程序根目录的文件

Example: config = require('../config/config');示例: config = require('../config/config');

The folder named.. is the parent folder helps in making the path to the file, which means we can go up for two levels with this../名为.. 的文件夹是帮助创建文件路径的父文件夹,这意味着我们可以使用此../

When you compare (.) and (..), (.) means current location where as.. means two levels up above the current one.当您比较 (.) 和 (..) 时,(.) 表示当前位置,而 as.. 表示比当前位置高两级。

also,还,

Try checking ./Config with Caps instead of ./config尝试使用 Caps 而不是./config检查./Config

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM