KAEDE Hack blog

kaede0902 技術ブログ お仕事募集中。

Automate module install by Package.json

package.json is what

bg

In remote work, I have a chance to touch node js work.
That means I have to use npm model.
Yeah, chance, that is the point. I had to use that,
but this, taught me. How to use and understand this.
Thanks to the P.M.
I got this error for just installing modules by npm.

f:id:kei_s_lifehack:20191017231123p:plain

what is the package.json

  • It is modules list, for example: (crypto, node-rsa,)
  • It shows dependencies and Dev dependecies.

qiita.com

dif between README.md

For just modules list, we have a README.md.
How about writing modules here, instead of using package.json?
No. That json file does much more.

Auto writing modules list

when installing another modules in need, appeding --save
After npm inti and return return return return return......

techacademy.jp

npm install --save pbkdf2
{
  "name": "ls",
  "version": "1.0.0",
  "description": "## pushing test",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "pbkdf2": "^3.0.17"
  }
}

It writes module dependencies list in json!!!
And this enable install everything on this list
by just npm --install.

Conclusion

  • In Node, npm, package.json is useful.
  • It written automatically, adding --save when install modules.
  • And it enable install everything in the json just npm install

Use package.json