What is a Package?
A package in Node.js contains all the files you need for a module.
Modules are JavaScript libraries you can include in your project.
Download a Package
Downloading a package is very easy.
Open the command line interface and tell NPM to download the package you want.
I want to download a package called follow-redirects:
npm i follow-redirects
Test the Package On Runkit
var followRedirects = require("follow-redirects")
const { http, https } = require('follow-redirects');
http.get('http://bit.ly/900913', response => {
response.on('data', chunk => {
console.log(chunk);
});
}).on('error', err => {
console.error(err);
});
RunKit notebooks completely remove the friction of trying new ideas. With one click you’ll have a sandboxed
JavaScript environment where you can instantly switch node versions, use every npm module without having to wait to install it, and even visualize your results. No more configuration, just straight to coding.
Something Else Important Maybe You need
Find and automatically fix open source vulnerabilities
Use the Snyk Online tools you can get the Package Health Score.
Let get the follow-redirects’s Health Score:
You can get more detail info about package follow-redirects’s vulnerabilities on the Snyk page.
Modify the third-party package’s Code and use it directly
- Fork the code to you github
- Change the code and push it to you github
- Use this commond
npm install [your github name]/[package name]
in your project
For example, My GitHub is earthandy and I want to use hexo-generator-amp which I forked from tea3, just use:
npm install earthandy/hexo-generator-amp --save