官术网_书友最值得收藏!

Testing our Node installation

Let's make sure your Node installation is working properly. Check the version number with node -v. We will be shown a version number, as follows:

node -v
v0.8.15

Now let's open up the Node console. This is an interactive tool that lets you run JavaScript right from your command line! It can be very helpful if you want to try out small ideas in code and receive immediate feedback. We'll see later that CoffeeScript provides an equivalent console.

Run this:

node

You will be presented with a prompt. Try entering some JavaScript code, and hit Enter to execute.

> "Hello, world!"
'Hello, world!'
> var x = 3 + 7
undefined
> x / 2
5

Tip

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Testing npm

We'll also check if npm is installed. npm is the Node package manager. It is a set of utilities for installing and managing tools and libraries written for Node. It is backed by https://npmjs.org/, the official online repository for Node packages. Almost any public code written for Node will be published in the repository and can be installed seamlessly with a single npm command.

If you have version 0.6.3 or above of Node, it comes with npm automatically. If you are still in the Node console, hit Ctrl + D to close it and return to your regular command line.

npm -v

If you see a version number, you have npm and can continue on to the next step.

Tip

If you don't have npm installed, the best way to get it is to upgrade to a recent version of Node following the instructions stated earlier. If you really cannot upgrade your version of Node, follow the installation instructions at https://github.com/isaacs/npm/.

主站蜘蛛池模板: 石狮市| 仪征市| 舞钢市| 北流市| 南昌县| 兴海县| 宁阳县| 临泉县| 旬邑县| 龙游县| 台中县| 祁阳县| 阿勒泰市| 松滋市| 锡林郭勒盟| 乌鲁木齐市| 许昌县| 德江县| 贺兰县| 河源市| 麟游县| 抚远县| 鹰潭市| 治县。| 新郑市| 商水县| 获嘉县| 南通市| 灵武市| 资阳市| 得荣县| 那坡县| 普宁市| 会昌县| 嘉定区| 晋中市| 马边| 康乐县| 连平县| 维西| 衡阳市|