Romil Singh Tomar
Romil Singh Tomar

Reputation: 25

How to create package.json for install node dependencies?

I am trying to install dependencies by npm install, there is need a package.json file that should include all the dependencies that need to install. I am not aware of how to create that package.json file.

These are the dependencies that I want to install by run only npm install: 1- MySQL, 2- express, 3- request, 4- md5, 5- nodemailer, 6- google-polyline.

Upvotes: 0

Views: 1871

Answers (2)

Maciek
Maciek

Reputation: 88

package.json file is modified automatically when you add some dependencies.

In the very beginning you need to initialize your app with:

npm init

then install what you need use: npm i mysql

https://www.npmjs.com/package/mysql

and so on for other dependencies

Upvotes: 0

Mickael B.
Mickael B.

Reputation: 5205

You can run npm init to run a questionnaire to generate a package.json or run npm init -y to generate a default package.json.

See this documentation.

Here is how a default package.json looks like:

{
    "name": "my_package",
    "description": "",
    "version": "1.0.0",
    "main": "index.js",
    "scripts": {
      "test": "echo \"Error: no test specified\" && exit 1"
    },
    "repository": {
      "type": "git",
      "url": "https://github.com/ashleygwilliams/my_package.git"
    },
    "keywords": [],
    "author": "",
    "license": "ISC",
    "bugs": {
      "url": "https://github.com/ashleygwilliams/my_package/issues"
    },
    "homepage": "https://github.com/ashleygwilliams/my_package"
  }

Then when you run npm install some_package it will be added to the denpendencies.

Upvotes: 2

Related Questions