本文共 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基本环境 ”。
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版本。Click on “Next” Button. Accept License Agreement and Click on “Next” Button.
点击“下一步”按钮。 接受许可协议,然后单击“下一步”按钮。
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\npmNOTE:
PATH=C:\Users\[username]\AppData\Roaming\npm;D:\NodeJS.V.0.12.0\;%PATH%
在这里,我们可以观察到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注意 :
PATH=C:\Users\[username]\AppData\Roaming\npm;D:\NodeJS.V.0.12.0\;%PATH%
Now we are able to see “>” prompt, that means our Node JS Base Environment Setup is done.
现在我们可以看到“>”提示,这意味着我们的Node JS基本环境设置已完成。
node –v
node –v
We can also use Ctrl + D OR use Ctrl + C Twice to exit from Node CLI.
我们还可以使用Ctrl + D或使用Ctrl + C两次退出Node CLI。
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/