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

前端 未结 25 2041
有刺的猬
有刺的猬 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: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 .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.

提交回复
热议问题