编程语言
首页 > 编程语言> > The NPM(Node Package Manager) Universe

The NPM(Node Package Manager) Universe

作者:互联网

NPM: node package manager

1. A library of thousands of packages published by other developers that we can use for free

2. A command line tool to easily install and manage those packages in out node projects

examples: Jokes and Color

https://www.npmjs.com/package/give-me-a-joke

https://www.npmjs.com/package/colors

Step 1: install packages:

npm i give-me-a-joke

npm i colors

Step 2: require package name

Step 3: call functions accroding to particular API

//index.js
const jokes = require("give-me-a-joke"); const colors = require("colors"); jokes.getRandomDadJoke(function (joke) { console.log(joke.rainbow); });

npm i -g cowsay在大路径下面引入global package

npm link cowsay在单个小路径下link引入的package名称,然后在js文件里面require

 

 

标签:NPM,Node,node,package,joke,colors,Manager,npm,install
来源: https://www.cnblogs.com/LilyLiya/p/14354954.html