博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Node JS环境设置– Node.js安装
阅读量:2533 次
发布时间:2019-05-11

本文共 4064 字,大约阅读时间需要 13 分钟。

In my previous post, we have discussed about ““. Now we have some idea about what is Node JS and what is not Node JS.

在我以前的文章中,我们讨论了“ ”。 现在我们对什么是Node JS和什么不是Node JS有了一些了解。

In this post, we will discuss about “How to setup Node JS Base Environment” in Windows OS and Mac OS X.

在本文中,我们将讨论Windows OS和Mac OS X中的“ 如何设置Node JS基本环境 ”。

Windows上的Node JS基本环境设置 (Node JS Base Environment Setup on Windows)

  1. Access Node JS Official Website “”

    Here we can find “INSTALL” button. If we want to download latest stable version, we can click on this button.

    If we want to select Node JS Platform based on our Hardware and Software requirements like Windows 32bit or 64bit OS, please click on “Downloads” button and select your required Node JS version to download.

    在这里我们可以找到“安装”按钮。 如果要下载最新的稳定版本,可以单击此按钮。

    如果我们要根据我们的硬件和软件要求(例如Windows 32位或64位操作系统)选择Node JS平台,请单击“下载”按钮,然后选择要下载的Node JS版本。

  2. Please click on “INSTALL” button to download latest Node JS Platform Version 0.12.0, this is the latest version as of writing this post.

    请单击“安装”按钮以下载最新的Node JS平台版本0.12.0,这是撰写本文时的最新版本。
  3. Please double click on “node-v0.12.0-x64.msi” file to start Installation process.

    Click on “Next” Button. Accept License Agreement and Click on “Next” Button.

    点击“下一步”按钮。 接受许可协议,然后单击“下一步”按钮。

  4. Choose your required location to install.
  5. Choose Default values and click on “Install” Button.
  6. Open Node JS Platform Home in your Explorer.

    Here we can observe node.exe and npm.cmd files and also “node_modules” folder.

    Now onwards, we will refer the following names for easier discussion purpose

    NODSJS_HOME= D:\NodeJS.V.0.12.0

    NODEJS_MODULES= D:\NodeJS.V.0.12.0\node_modules
    NODEJS_NPM= D:\NodeJS.V.0.12.0\node_modules\npm

    NOTE:

    • If we use Windows Installer like “node-v0.12.0-x64.msi” or exe file then we doesn’t need to do anything to SYSTEM variables. This installer will take care of everything.
    • If we use other formats or if these are missing in your system environment variables, please add the following variables to SYSTEM properties;

      PATH=C:\Users\[username]\AppData\Roaming\npm;D:\NodeJS.V.0.12.0\;%PATH%

    在资源管理器中打开Node JS Platform Home。

    在这里,我们可以观察到node.exe和npm.cmd文件以及“ node_modules”文件夹。

    现在起,我们将引用以下名称以方便讨论

    NODSJS_HOME = D:\ NodeJS.V.0.12.0

    NODEJS_MODULES = D:\ NodeJS.V.0.12.0 \ node_modules
    NODEJS_NPM = D:\ NodeJS.V.0.12.0 \ node_modules \ npm

    注意

    • 如果我们使用Windows Installer(例如“ node-v0.12.0-x64.msi”或exe文件),则无需对SYSTEM变量做任何事情。 该安装程序将处理所有事情。
    • 如果我们使用其他格式,或者您的系统环境变量中缺少这些格式,请在SYSTEM属性中添加以下变量;

      PATH=C:\Users\[username]\AppData\Roaming\npm;D:\NodeJS.V.0.12.0\;%PATH%

  7. Open Command prompt at NODSJS_HOME or anywhere like D:\
  8. Run “node.exe” command

    Now we are able to see “>” prompt, that means our Node JS Base Environment Setup is done.

    现在我们可以看到“>”提示,这意味着我们的Node JS基本环境设置已完成。

  9. Check Node JS Version: Use the following command to know your Node JS Version from Command prompt.

    node –v

    node –v

  10. Exit from Node CLI: We can use “process.exit()” command to exit from Node CLI.

    We can also use Ctrl + D OR use Ctrl + C Twice to exit from Node CLI.

    我们还可以使用Ctrl + D或使用Ctrl + C两次退出Node CLI。

Mac OS X上的Node.js基本环境设置 (Node.js Base Environment Setup on Mac OS X)

For Mac OS X, download the pkg installer and run it. You will get below screens in order.

对于Mac OS X,下载pkg安装程序并运行它。 您将按顺序获得以下屏幕。

As you can see from above image, /usr/local/bin should be in the PATH variable. Usually it’s there by default but you can check it using below command.

从上图可以看到, / usr / local / bin应该在PATH变量中。 通常情况下,默认情况下它存在,但是您可以使用以下命令进行检查。

pankaj:~ pankaj$ echo $PATH/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/Library/Java/JavaVirtualMachines/jdk1.7.0_60.jdk/Contents/Home/bin:/usr/local/apache-maven-3.0.5/bin:pankaj:~ pankaj$

Below are some sample commands to check the version and start Node CLI and exit it.

以下是一些示例命令,用于检查版本并启动Node CLI并退出。

pankaj:~ pankaj$ node -vv0.12.1pankaj:~ pankaj$ node> process.exit();pankaj:~ pankaj$ node> (^C again to quit)> pankaj:~ pankaj$

Before starting some simple Node JS examples, we will discuss about Major Components of Node JS Platform in next post.

在开始一些简单的Node JS示例之前,我们将在下一篇文章中讨论Node JS Platform的主要组件

翻译自:

转载地址:http://wtqzd.baihongyu.com/

你可能感兴趣的文章
阿里负载均衡,配置中间证书问题(在starcom申请免费DV ssl)
查看>>
转:How to force a wordbreaker to be used in Sharepoint Search
查看>>
MySQL存储过程定时任务
查看>>
Python中and(逻辑与)计算法则
查看>>
POJ 3267 The Cow Lexicon(动态规划)
查看>>
设计原理+设计模式
查看>>
音视频处理
查看>>
tomcat 7服务器跨域问题解决
查看>>
前台实现ajax 需注意的地方
查看>>
Jenkins安装配置
查看>>
个人工作总结05(第二阶段)
查看>>
Java clone() 浅拷贝 深拷贝
查看>>
深入理解Java虚拟机&运行时数据区
查看>>
02-环境搭建
查看>>
spring第二冲刺阶段第七天
查看>>
搜索框键盘抬起事件2
查看>>
阿里百川SDK初始化失败 错误码是203
查看>>
透析Java本质-谁创建了对象,this是什么
查看>>
BFS和DFS的java实现
查看>>
关于jquery中prev()和next()的用法
查看>>