- 在 nodejs 官网下载安装。网址:https://nodejs.org/en/
安装完如图所示:
- 安装完 node,在终端输入命令查看 node 版本:
node−vv8.1.2// npm -v
5.0.3
看到node和npm的版本号,就说明node.js已经成功安装!
ok! 启动npm
$ npm start
npm ERR! missing script: start
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/a198/.npm/_logs/2017-06-20T05_51_43_318Z-debug.log
这是因为在package.json的 scripts 中没有定义start为字段的命令。修改package.json文件为:
{
"name": "angularJSLib",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start":"echo 'hello world!'"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"angular": "^1.6.4"
}
}
运行
$ npm start
angularJSLib@1.0.0 start /Users/a198/Desktop/angularJSDemo/angularJSLib echo 'hello world!'
hello world!