Languages
[Edit]
EN

npm - create package.json file

9 points
Created by:
AnnLen
13390

In this short article, we would like to show how to create package.json file with npm.

Quick solution (run in the command line in the project directory):

npm init

Note: the command carries user through the steps setting basic configuration.

 

Usage example

To run npm init we should create some directory for our new project.

$ mkdir test-project
$ cd test-project
$ 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: (test-project) 
version: (1.0.0) 
description: 
entry point: (index.js) 
test command: 
git repository: 
keywords: 
author: 
license: (ISC) 
About to write to /home/john/Desktop/test-project/package.json:

{
  "name": "test-project",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}


Is this OK? (yes) 

Result:

$ ls -al
total 12
drwxrwxr-x 2 john john 4096 lut 22 12:32 .
drwxr-xr-x 8 john john 4096 lut 22 12:31 ..
-rw-rw-r-- 1 john john  205 lut 22 12:32 package.json
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join