I\'m getting following Console Error.
Error : Cannot find module
Here is the full error i\'m getting in console. What should I do?
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.
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.
I changed name of my Project's folder and It's worked , i don't know why :)
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.
Create the .js file inside the main directory not inside the sub folders such as public or src.
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