1

I am trying to execute a file using the terminal included in Visual Studio Code. However, I cannot seem to get it working and end up receiving the following error message:

Example, "node myfile.js" --> module.js:549
    throw err;
    ^
Error: Cannot find module c:\somepath

Is there anyone who knows what the problem might be?

2
  • if you enter this command in VS powershell terminal: "npm config get prefix" does it gives you a path linked with your VS? If not, maybe 1- nodejs is not in your path; 2- you have not installed nodejs module by modifying your VS installation or 3- maybe a problem with VS version of nodejs. Commented Aug 24, 2018 at 20:24
  • Do you mean that it works in a regular PowerShell window but not in the integrated terminal? Commented Aug 26, 2018 at 12:46

2 Answers 2

1

I had your problem before

you should run cmd as administrator.

then type : powershell set-Executionpolicy Remotesigned

and

enter.

now you can run node in vscode .

Sign up to request clarification or add additional context in comments.

2 Comments

Hi Ali. Could you be more clear on your answer? For instance, which cmd you mean to "run as administrator" (is it VSCode, Node, Powershell?). Also, you don't have to say "enter". And for the benefit of clarity, put commands/code snippets in code blocks. Thanks for contributing!
Hi Ali. Could you be more clear on your answer? For instance, which cmd you mean to "run as administrator" (is it VSCode, Node, Powershell?). Also, you don't have to say "enter". And for the benefit of clarity, put commands/code snippets in code blocks. Thanks for contributing!
1

Run Visual studio as Admin and also the Node package location should be accessible for your user

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.