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

Node.js No-frills npm

黄舟
Release: 2017-01-17 15:35:32
Original
1385 people have browsed it

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
Copy after login

npm upgrade

Under windows

[code]npm install npm -g
Copy after login
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
Copy after login

Installation Module—express module

[code]npm install express
Copy after login

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

Use the module

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

Search module
[code]npm search express
Copy after login
Create module

Terminal command:
npm init
Copy after login


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"                    // 护照
}
Copy after login

Registered user

[code]npm adduser
Copy after login
Publish module
[code]npm publish
Copy after login


##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)!


Related labels:
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template