简体   繁体   English

无法在 VS Code 终端上设置路径

[英]Not able to set path on VS Code terminal

Don't know why VS Code is fetching the path which I haven't even set.不知道为什么 VS Code 正在获取我什至没有设置的路径。 Please help... I am a beginner.请帮助...我是初学者。

My project's parent folder is on Desktop and I have set the path accordingly on VS Code's terminal, and I use bash.我的项目的父文件夹在桌面上,我在 VS Code 的终端上相应地设置了路径,我使用 bash。 To run the JS code I am using Node.要运行 JS 代码,我使用的是 Node.js。 But here is the trick, the path which I've set is perfectly shown on the terminal and so after giving commands to run the file using node, earlier it used to work properly but now it throws an error stating "Cannot find module" and shows a different path where I haven't even saved my file and folders.但这里有诀窍,我设置的路径完美地显示在终端上,因此在发出使用节点运行文件的命令后,之前它曾经可以正常工作,但现在它抛出一个错误,指出“找不到模块”和显示了一个不同的路径,我什至没有保存我的文件和文件夹。

It has to be found on 'C:\\Users...' but now it is directing on 'C:\\Program Files...'它必须在“C:\\Users...”上找到,但现在它指向“C:\\Program Files...”

PFB the error message. PFB 错误消息。

$ node /02Basics/08ConditionalRoles.js
internal/modules/cjs/loader.js:968
  throw err;
  ^

Error: Cannot find module 'C:\Program Files\Git\02Basics\08ConditionalRoles.js'```

By using just a / , Git Bash interprets that as the directory / , which is located at C:\\Program Files\\Git\\ .通过仅使用/ ,Git Bash 将其解释为目录/ ,该目录位于C:\\Program Files\\Git\\ If you want to use local pathing, include a .如果要使用本地路径,请包含. at the beginning.一开始。 This tells bash to start at the current working directory.这告诉 bash 从当前工作目录开始。

TLDR: Use this and it should work: TLDR:使用它,它应该可以工作:

./02Basics/08ConditionalRoles.js

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM