その3から続き
11. Node.jsのプロジェクトを作成します。「npm init」というコマンドを入力します。いくつか聞かれますが、Enterで進みます。
$ npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.
See `npm help init` for definitive documentation on these fields
and exactly what they do.
Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any time to quit.
package name: (temp)
version: (1.0.0)
description: get temperature
entry point: (index.js)
test command:
git repository:
keywords:
author: Soarstech
license: (ISC)
About to write to /home/soarstech/temp/package.json:
{
"name": "temp",
"version": "1.0.0",
"description": "get temperature",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Soarstech",
"license": "ISC"
}
Is this OK? (yes) yes
12. 最後までいくと、同じフォルダに、package.jsonというファイルが出来ます。
13. package.jsonをエディタで開きます。
{
"name": "temp",
"version": "1.0.0",
"description": "get temperature",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Soarstech",
"license": "ISC"
}
14. “scripts”のところに、下記を追加します。
"start": "node index.js",
最後に、下記を追加します。
"private": true
追加後は、下記のようになります。
{
"name": "temp",
"version": "1.0.0",
"description": "get temperature",
"main": "index.js",
"scripts": {
"start": "node index.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Soarstech",
"license": "ISC",
"private": true
}
その5へ続く