donaricano-btn

Using a package.json

- The best way to manage locally installed npm packages is to create a package.json file


1.package.json

1) It serves as documentation for what packages your project depends on

2) It allows you to specify the versions of package that your project can use using semantic versioning rules

3) Makes your build reproducable which means that its way easier to share with other developer


2. Requirements

- a package.json must have

1) name

2) version


3. Creating a package.json

3_1. To create a package.json

- This will initate a command line questionnaire that will conclude with the creation of a package.json in the directory you initiated the command


3_2. The --yes init flag

- If you are comfortable with using a package.json you'd like a more expedited experience

you can get a default package.json by running npm init with the --yes or -y flag

- This will ask you only one question, Author, Otherwise it will fill in default values


4. Specifying packages

- To specify the packages your project depends on, you need to list packages you'd like to use in your package.json file.

- There are 2 types of packages you can list


1) dependencies : these packages are required by your application in production

2) devDependencies : these packages are only needed for development and testing


4_1. Manually editing your package.json

- You can manually edit your package.json. You'll need to create an attribute in the package object called dependencies that points to an object.

- If you have dependencies you only need to use during local development,


4_2. The --save and --save-dev install flags

- To add an entry to your package.json's dependencies:

- To add an entry to your package.json's devDependencies:








'Tools > npm' 카테고리의 다른 글

[npm] Installing npm packages  (0) 2016.06.21
[npm] 1. What is NPM?  (0) 2016.02.23
블로그 이미지

리딩리드

,