npm常用命令

  1. npm init [-f|--force|-y|--yes]
    This will ask you a bunch of questions, and then write a package.json for you.
    If you invoke it with -f, --force, -y, or --yes, it will use only defaults and not prompt you for any options.

2.npm install
Install the dependencies in the local node_modules folder.
By default, npm install will install all modules listed as dependencies in package.json

-P, --save-prod: Package will appear in your dependencies. This is the default unless -D or -O are present.
-D, --save-dev: Package will appear in your devDependencies.
-E, --save-exact: Saved dependencies will be configured with an exact version rather than using npm's default semver range operator.

3.npm ls
参数:
global
List packages in the global install prefix instead of in the current project.
depth
Max display depth of the dependency tree.
prod
Display only the dependency tree for packages in dependencies.
dev
Display only the dependency tree for packages in devDependencies.
示例;npm ls --depth=0 -g

4.npm uninstall
npm uninstall [<@scope>/]<pkg>[@<version>]... [-S|--save|-D|--save-dev|-O|--save-optional|--no-save]
aliases: remove, rm, r, un, unlink

--no-save: Package will not be removed from your package.json file.

5.npm update [-g] [<pkg>...]
aliases: up, upgrade

6.npm cache clean [<path>]
aliases: npm cache clear, npm cache rm
7.npm config
npm config list
npm config set <key> <value> [-g|--global]
npm config get <key>

修改源地址为淘宝 NPM 镜像:
npm config set registry http://registry.npm.taobao.org/
修改源地址为官方源:
npm config set registry https://registry.npmjs.org/

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 查看npm命令: 初始化一个基于node的项目,会创建一个配置文件package.json(两种方式): 安装模块...
    buer_jing阅读 12,874评论 1 9
  • npm是什么 NPM的全称是Node Package Manager,是随同NodeJS一起安装的包管理和分发工具...
    街角仰望阅读 4,344评论 0 0
  • npm常用命令 (1)npm install moduleNames 安装Node模块 注意事项:如果在使...
    2d9ec85f6803阅读 4,536评论 0 1
  • 国内镜像 清理缓存 设置代理 npm设置列表 npm config 所有的api npm 常用命令npm查看全局安...
    白水螺丝阅读 5,632评论 0 0
  • 背着我的双肩包,拿着单反,穿上我的帆布鞋,听着音乐去感受每一段旅程中的每一点点滴滴,每次流浪只想自己有成长,成为自...
    槿子阅读 2,622评论 2 3

友情链接更多精彩内容