$ pwd
/home/bg1/project/cloud/github.com/Sample/electron/app/app/src/app_
$ 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 json` 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: (app_) app_
version: (1.0.0) 1.0.0
description: electron sample
entry point: (index.js) main.js
test command: start
git repository: -
keywords: -
author: B.G
license: (ISC) MIT
About to write to
/home/bg1/project/cloud/github.com/Sample/electron/app/app/src/app_/package.json:
{
"name": "app_",
"version": "1.0.0",
"description": "electron sample",
"main": "main.js",
"scripts": {
"test": "start"
},
"repository": {
"type": "git",
"url": "-"
},
"keywords": [
"-"
],
"author": "B.G",
"license": "MIT"
}
Is this OK? (yes) yes
$
$ ls
package.json
$ vi main.js
$ vi index.html
$ ls
index.html main.js package.json
$ vi package.json
$ npm install electron
> electron@4.0.6 postinstall /home/bg1/project/cloud/github.com/Sample/electron/app/app/src/app_/node_modules/electron
> node install.js
Downloading tmp-3567-1-SHASUMS256.txt-4.0.6
[============================================>] 100.0% of 4.74 kB (4.74 kB/s)
npm notice created a lockfile as package-lock.json. You should commit this file.
+ electron@4.0.6
added 145 packages from 140 contributors and audited 201 packages in 72.441s
found 0 vulnerabilities
╭───────────────────────────────────────────────────────────────╮
│ │
│ New minor version of npm available! 6.4.1 → 6.8.0 │
│ Changelog: https://github.com/npm/cli/releases/tag/v6.8.0 │
│ Run npm install -g npm to update! │
│ │
╰───────────────────────────────────────────────────────────────╯
$
Expressと同様、ローカルインストールの方が安全なのでいいとおもう。
これで、npm startで実行しようとしたら、
$ npm start
> app_@1.0.0 start /home/bg1/project/cloud/github.com/Sample/electron/app/app/src/app_
> electron .
/home/bg1/project/cloud/github.com/Sample/electron/app/app/src/app_/node_modules/electron/dist/electron:
error while loading shared libraries: libXss.so.1: cannot open shared
object file: No such file or directory
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! app_@1.0.0 start: `electron .`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the app_@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely
additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/bg1/.npm/_logs/2019-03-04T14_18_14_340Z-debug.log
$
$ pwd
/home/bg1/project/cloud/github.com/Sample/express/express/express/src/express_
$ 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 json` 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: (express_) express_
version: (1.0.0) 1.0.0
description: express sample
entry point: (index.js) index.js
test command: test
git repository: -
keywords: -
author: B.G
license: (ISC) MIT
About to write to
/home/bg1/project/cloud/github.com/Sample/express/express/express/src/express_/package.json:
{
"name": "express_",
"version": "1.0.0",
"description": "express sample",
"main": "index.js",
"scripts": {
"test": "test"
},
"repository": {
"type": "git",
"url": "-"
},
"keywords": [
"-"
],
"author": "B.G",
"license": "MIT"
}
Is this OK? (yes) yes
$
$ npm install express
npm notice created a lockfile as package-lock.json. You should commit this file.
+ express@4.16.4
added 48 packages from 36 contributors and audited 121 packages in 4.512s
found 0 vulnerabilities
$ ls
node_modules package-lock.json package.json
$