Change directory in Node.js command prompt

社会主义新天地 提交于 2019-12-20 08:56:50

问题


I want to move to another directory in Node.js command prompt but when I open the Node.js cmd window it doesn't show me any path. Here is the screenshot of the Node.js cmd window:

Now if i want to change directory to D:\abc then how can i do it here?


回答1:


That isn't the Node.js command prompt window. That is a language shell to run JavaScript commands, also known as a REPL.

In Windows, there should be a Node.js command prompt in your Start menu or start screen:

Which will open a command prompt window that looks like this:

From there you can switch directories using the cd command.




回答2:


To switch to the another directory process.chdir("../");




回答3:


If you mean to change default directory for "Node.js command prompt", when you launch it, then (Windows case)

  1. go the directory where NodeJS was installed
  2. find file nodevars.bat
  3. open it with editor as administrator
  4. change the default path in the row which looks like

    if "%CD%\"=="%~dp0" cd /d "%HOMEDRIVE%%HOMEPATH%"
    

with your path. It could be for example

    if "%CD%\"=="%~dp0" cd /d "c://MyDirectory/"

if you mean to change directory once when you launched "Node.js command prompt", then execute the following command in the Node.js command prompt:

     cd c:/MyDirectory/



回答4:


Type .exit in command prompt window, It terminates the node repl.




回答5:


.help will show you all the options. Do .exit in this case



来源:https://stackoverflow.com/questions/31217771/change-directory-in-node-js-command-prompt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!