Issue setting up node.js

it’s my firt time using node.js today and I was faced with this issue. When trying to run hello.js in my terminal, I get this message :

Error: Cannot find module ‘/Users/antoinelafonta/hello.js’
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: ‘MODULE_NOT_FOUND’,
requireStack:

It’s running fine when using the VsCode terminal. I’ve tried to set up a PATH to the Visual Studio App, but the message stays the same.

Any ideas ?

Hello and welcome to the forums! :wave:

What folder is hello.js in? It seems to be looking for it directly in /Users/antoinelafonta/. Assuming it’s not in this folder, chances are the terminal you’re using is targeting that folder, and not the folder with the actual code. To check this you can type:

pwd

And if it’s not the folder with the code you can use this command to re-target the terminal into that folder:

cd "File path to folder here"

Happy coding! :smile:

2 Likes

Thanks @notlyall, it works now !

1 Like

BRO… its not working to me…!!!

Please share the error message you’re getting :slight_smile:

this error comes in my vscode always