Change directory in Node.js command prompt

前端 未结 7 462
不知归路
不知归路 2021-01-31 15:57

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 wind

相关标签:
7条回答
  • 2021-01-31 16:03

    Add the \d [dir] attribute to the cd command like this:

    cd \d %yourdir%:\
    
    0 讨论(0)
  • 2021-01-31 16:03
    1. Open file nodevars.bat
    2. Just add your path to the end, "%HOMEDRIVE%%HOMEPATH% /file1/file2/file3
    3. Save file nodevars.bat

    This work even with Swedish words

    0 讨论(0)
  • 2021-01-31 16:12

    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/
    
    0 讨论(0)
  • 2021-01-31 16:13

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

    0 讨论(0)
  • 2021-01-31 16:13

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

    0 讨论(0)
  • 2021-01-31 16:21

    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:

    Windows Search for node.js

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

    From there you can switch directories using the cd command.

    0 讨论(0)
提交回复
热议问题