'Tools/npm'에 해당되는 글 3건

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
블로그 이미지

리딩리드

,
donaricano-btn

Installing npm packages 

There are two ways to install npm packages

- If you want to depend on the package from your own module using something like node.js require, then you want to install locally, which is npm install's default behavior

If you want to use it as a command line tool, something like the grunt CLI, then you want to install it globally



1. Locally

- This will create the node_modules directory in your current directory and will download the package to that directory


1_1. Example


1_2. Using the installed package

Once the package is in node_modules, you can use it in your code.

it you are creating a Node.js module, you can require it

- Run the code using node index.js It should output [2, 3]


2. Globally


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

[npm] Using a package.json  (0) 2016.06.21
[npm] 1. What is NPM?  (0) 2016.02.23
블로그 이미지

리딩리드

,

[npm] 1. What is NPM?

Tools/npm 2016. 2. 23. 14:53
donaricano-btn
  • NPM
1. Define

- npm(node package manager) is a default package manager for the Javascript runtime environment   Node.js

- As of Node.js version 0.6.3 NPM is bundled and installed automatically with the environment

- NPM runs through the command line and manages dependencies for an application 

2. About

- Once you're depending on this code from other developers, npm makes it really easy to check to see if they've made any updates to it, and to download those updates when they're made

- It's a way to reuse code from other developers, and also a way to share your code with them, and it makes it easy to manage the different versions of code

3. package.json

- These bits of reusable code are called packages, or sometimes modules.
- A package is just a directory with one or more files in it, that also has a filed called "package.json" with some meta data about this package 
- A typical application such as a website, will depend on dozens or hundreds of packages

4. packages

- You can find packages to help you build your application by browsing the npm web site









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

[npm] Using a package.json  (0) 2016.06.21
[npm] Installing npm packages  (0) 2016.06.21
블로그 이미지

리딩리드

,