Home >Web Front-end >JS Tutorial >Node.js No-frills npm

Node.js No-frills npm

黄舟
黄舟Original
2017-01-17 15:35:321292browse

Learning points

View version

Upgrade

Install module

Use module

View module list

Uninstall module

Update module

Search module

Create module

Publish module

REPL

npm package Manager

View version

[code]npm -v

npm upgrade

Under windows

[code]npm install npm -g
lunix under
[code]sudo npm install npm -g
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
npm@2.14.2 /usr/local/lib/node_modules/npm

Installation Module—express module

[code]npm install express

The installation directory is in the node_modules folder under the current project

Use the module

[code]var express = require('express');
View the installed module
[code]npm ls
Uninstall and install Module
[code]npm unstall express
Update module
[code]npm update express

Search module
[code]npm search express
Create module

Terminal command:
npm init


Then enter as required until Is this ok? (yes)

Finally generate the package.json file

[code]{
  "name": "wolf",                     // 模块名称
  "version": "1.0.0",                 // 版本号
  "description": "海涵狼群俱乐部",    // 描述
  // main 字段是一个模块ID,它是一个指向你程序的主要项目。
  // 就是说,如果你包的名字叫 express,然后用户安装它,然后require("express")。
  "main": "index.js",                 
  "dependencies": {                   // 依赖包列表
    "express": "^4.14.0"
  },
  "devDependencies": {},
  "scripts": {                        // 测试
    "test": "make test",
    "start": "node server.js"
  },
  "repository": {                     // github账号
    "type": "git",
    "url": "http://lamport.me/club"
  },  
  "author": "zhang",                   // 作者
  "license": "ISC"                    // 护照
}

Registered user

[code]npm adduser
Publish module
[code]npm publish


##Node.js REPL (Read Eval Print Loop) Interactive interpreter
Terminal starts node


Exit twice ctrl + c

The above is the content of Node.js unpretentious npm, more For related content, please pay attention to the PHP Chinese website (www.php.cn)!


Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Node.js first try cryNext article:Node.js first try cry