First time using node.js - “ReferenceError: node is not defined”

后端 未结 7 1952
刺人心
刺人心 2021-02-01 02:47

I just installed node.js. I tried writing node -v that should check the version - and it\'s not working. this is the output:

 > node -v ReferenceError: node          


        
相关标签:
7条回答
  • 2021-02-01 03:29

    Thanks for this help.

    If you are using windows, like me, and want a desktop shortcut and you already have the nice node.js desktop icon, edit the shortcut properties like this:

    1. right click and select properties
    2. click change Icon, select the current icon and click OK (to lock it in)
    3. in the target box, change it all to simply say cmd or c:\windows\System32\cmd.exe if you are pedantic.

    now you have a command prompt, with the node.js icon, that opens in the folder you expect, that responds correctly to the node -v command.

    0 讨论(0)
  • 2021-02-01 03:30

    Edit

    First time using node.js

    Although already answered, but just putting in my 2-cents,

    Normally, the first time users would trip over it, so am posting some screen shots, and that OP wants to try node -v, so making it a bit easier to follow.

    The Wrong !!


    The Correct !!


    or you can do ..

    Hope it helps someone.!

    0 讨论(0)
  • 2021-02-01 03:39

    Follow below Steps:

    1. Open command prompt: RUN > CMD
    2. Navigate to folder where nodejs is installed: C:\users\name>cd path_of_nodejs
    3. Open nodejs: C:\path_of_nodejs>node
    4. Exit from node REPL mode: >process.exit()
    5. You are ready for your node commands: >node -v
    0 讨论(0)
  • 2021-02-01 03:49

    It looks like you have entered the node REPL and then typed node -v

    The good news is that this means node is working!

    To check the version from here you can type process.version to get the node version. Alternatively type process.exit() to exit the node REPL and get back to bash (or equivalent terminal).

    From here node -v should just output the node version.

    0 讨论(0)
  • 2021-02-01 03:49

    Instead of node.exe, try to run node from "Node.js command prompt".

    First, you should install nodejs.msi from nodejs.org.

    Once installation is completed, go to: Start > All Programs > Node.js > Node.js command prompt.

    It worked for me.

    0 讨论(0)
  • 2021-02-01 03:49

    Try opening up a new terminal (Run -> CMD) and then executing:

    node /your_file_name.js
    

    And to see which version you have installed, just execute:

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