sh Node.js - 节点包管理器(npm)

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sh Node.js - 节点包管理器(npm)相关的知识,希望对你有一定的参考价值。

#! /bin/bash

# Installs/Downloads a package in the current folder
npm install # -or- npm i
npm install <pkg>
npm install <pkg>@<tag>
npm install <pkg>@<version>
npm install <folder>
npm install <tarball file>
npm install <git:// url>

npm install gulp-cli -g # -or- --global (installs globally for all)

# Node Package Manager

npm

# has global and local dependency directories (default is local) = node_modules in current directory of project

# create new project (package.json)
npm init (—y)

# install dependency (and list in package.json)
npm i(nstall) x (—save-dev / -D)
npm i x@1.2.3 # specific version

# dependencies = necessary for the project to run
# devDependencies = nec. for developing the project 

# list dependencies
npm list (—depth=0)
npm outdated

# package-lock.json = ensure all (sub-)dependencies stay the same for every machine

npm update x ## updates to highest available minor version!

npm run $script (-s) # run script of package.json; -s silent
npm run <command> [-- <args>]


# Link local modules
npm link ../path/to/module # package.json:name = "@scoped/pkg"
require('@scoped/pkg');

以上是关于sh Node.js - 节点包管理器(npm)的主要内容,如果未能解决你的问题,请参考以下文章

NPM(node.js 包管理器)无法安装 tiddlywiki

Node.js入门 02:包管理器npm

如何将 npm(node.js 包管理器)添加到 PATH?

Node.js中的模块化,npm包管理器

NPM - Node Package Manager - Node 包管理器

初识npm