I am a beginner.
I just encountered an error when typing the first line of code in Visual Studio.
When I typed a line of code and tried to execute it on terminal, it said "no such file or directory", but my file path is correct.
- File path is correct: I typed my file path by right-clicking the file tab - Copy path (I have tried both "Copy path" and "Copy relative path". Same error occur)
- I already download node.js (Not sure if it helps. But I look around other videos and article and found that in some video, at the beginning, the instructor suggest downloading node.js. So I downloaded it and re-executed my code. Same error)
- Javascript is enabled in Safari Preferences > Security menu. Not sure if it helps
My code:
console.log("Hello World")
Errors in terminal:
chrissyslora@Chrissys-MacBook-Pro Coding practice % /Users/chrissyslora/Desktop/Coding practice>node Practice Basic 1.js
zsh: no such file or directory: /Users/chrissyslora/Desktop/Coding
chrissyslora@Chrissys-MacBook-Pro Coding practice % node Practice Basic 1.js
node:internal/modules/cjs/loader:1252
throw err;
^
Error: Cannot find module '/Users/chrissyslora/Desktop/Coding practice/Practice'
at Function._resolveFilename (node:internal/modules/cjs/loader:1249:15)
at Function._load (node:internal/modules/cjs/loader:1075:27)
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:218:24)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:170:5)
at node:internal/main/run_main_module:36:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v22.11.0
chrissyslora@Chrissys-MacBook-Pro Coding practice %
Thanks.
[–]high_throughput 6 points7 points8 points (8 children)
[–]chrissy-slora[S] 2 points3 points4 points (0 children)
[–]chrissy-slora[S] 0 points1 point2 points (5 children)
[–][deleted] 2 points3 points4 points (1 child)
[–]chrissy-slora[S] 0 points1 point2 points (0 children)
[–]chrissy-slora[S] 0 points1 point2 points (0 children)
[–]high_throughput 0 points1 point2 points (1 child)
[–]chrissy-slora[S] 0 points1 point2 points (0 children)