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

前端 未结 25 1830
有刺的猬
有刺的猬 2020-11-27 04:24

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

Here is the full error i\'m getting in console. What should I do?



        
相关标签:
25条回答
  • 2020-11-27 05:19

    For those who are using TypeScript, it's caused by incremental option in the compilerOptions of your settings.

    This causes to build tsconfig.tsbuildinfo file which stores all the data for cache. If you remove that file and recompile the project it should work straight away.

    0 讨论(0)
  • 2020-11-27 05:20

    What helped me was to place the .js file that I was working with in a new folder, drag and drop that folder into VS Code (to open the directory directly in VS Code), open the terminal in VS Code, and then simply type node <filename>.js (or in my case node index.js).

    I had already installed node on my system, but for whatever reason, I was still getting the error that you've mentioned, even when I typed the direct path to the file i.e. node /desktop/index.js.

    So, creating a new folder on my desktop, placing the .js file inside that folder, opening that folder within VS Code, and then typing node index.js in the terminal solved my issue.

    0 讨论(0)
  • 2020-11-27 05:21

    I changed name of my Project's folder and It's worked , i don't know why :)

    0 讨论(0)
  • 2020-11-27 05:23

    Hashan Gunathilaka was correct. this strange behavior exists. I just deleted the duplicates and closed the command prompt to open again in windows. Worked fine.

    0 讨论(0)
  • 2020-11-27 05:23

    Create the .js file inside the main directory not inside the sub folders such as public or src.

    0 讨论(0)
  • 2020-11-27 05:25

    When I was using the below command, I too was getting the same error:

    node .function-hello.js
    

    I changed my command to below command, it worked fine:

    node .\function-hello.js
    
    0 讨论(0)
提交回复
热议问题