0

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.

2
  • 1
    Run npm init -y to create an empty package.json, then npm i <dependency-1> <dependency-2> .... Otherwise you need to be more specific about your problem. Commented Apr 29, 2020 at 13:33
  • Does this answer your question? How do I create a package.json file? Commented Apr 29, 2020 at 14:03

2 Answers 2

2

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.