目录
选择命令行版本:
目录
概要
¥Synopsis
npm uninstall [<@scope>/]<pkg>...aliases: unlink, remove, rm, r, un
描述
¥Description
这将卸载一个包,完全删除代表它安装的所有 npm。
¥This uninstalls a package, completely removing everything npm installed on its behalf.
它还会从 package.json
中的 dependencies
、devDependencies
、optionalDependencies
和 peerDependencies
对象中删除包。
¥It also removes the package from the dependencies
, devDependencies
, optionalDependencies
, and peerDependencies
objects in your package.json
.
此外,如果你有 npm-shrinkwrap.json
或 package-lock.json
,npm 也会更新这些文件。
¥Further, if you have an npm-shrinkwrap.json
or package-lock.json
, npm will update those files as well.
--no-save
会告诉 npm 不要从你的 package.json
、npm-shrinkwrap.json
或 package-lock.json
文件中删除包。
¥--no-save
will tell npm not to remove the package from your package.json
, npm-shrinkwrap.json
, or package-lock.json
files.
--save
或 -S
将告诉 npm 从你的 package.json
、npm-shrinkwrap.json
和 package-lock.json
文件中删除该包。这是默认设置,但如果你的 npmrc
文件中有例如 save=false
,你可能需要使用它
¥--save
or -S
will tell npm to remove the package from your package.json
, npm-shrinkwrap.json
, and package-lock.json
files. This is the default, but you may need to use this if you have for instance save=false
in your npmrc
file
在全局模式下(即,将 -g
或 --global
附加到命令中),它将当前包上下文作为全局包卸载。在这种情况下,--no-save
被忽略。
¥In global mode (ie, with -g
or --global
appended to the command), it uninstalls the current package context as a global package. --no-save
is ignored in this case.
范围是可选的,并遵循 scope
的通常规则。
¥Scope is optional and follows the usual rules for scope
.
示例
¥Examples
npm uninstall sax
sax
将不再出现在你的 package.json
、npm-shrinkwrap.json
或 package-lock.json
文件中。
¥sax
will no longer be in your package.json
, npm-shrinkwrap.json
, or package-lock.json
files.
npm uninstall lodash --no-save
lodash
不会从你的 package.json
、npm-shrinkwrap.json
或 package-lock.json
文件中删除。
¥lodash
will not be removed from your package.json
, npm-shrinkwrap.json
, or package-lock.json
files.
配置
¥Configuration
save
-
默认值:
true
除非在使用npm update
时默认为false
¥Default:
true
unless when usingnpm update
where it defaults tofalse
-
类型:布尔值
¥Type: Boolean
将已安装的包作为依赖保存到 package.json
文件中。
¥Save installed packages to a package.json
file as dependencies.
与 npm rm
命令一起使用时,从 package.json
中删除依赖。
¥When used with the npm rm
command, removes the dependency from package.json
.
如果设置为 false
,也会阻止写入 package-lock.json
。
¥Will also prevent writing to package-lock.json
if set to false
.
global
-
默认值:false
¥Default: false
-
类型:布尔值
¥Type: Boolean
在 "global" 模式下运行,以便将包安装到 prefix
文件夹而不是当前工作目录。有关行为差异的更多信息,请参见 文件夹。
¥Operates in "global" mode, so that packages are installed into the prefix
folder instead of the current working directory. See folders for more on the differences in behavior.
-
包安装到
{prefix}/lib/node_modules
文件夹,而不是当前工作目录。¥packages are installed into the
{prefix}/lib/node_modules
folder, instead of the current working directory. -
bin 文件链接到
{prefix}/bin
¥bin files are linked to
{prefix}/bin
-
手册页链接到
{prefix}/share/man
¥man pages are linked to
{prefix}/share/man
workspace
-
默认值:
¥Default:
-
类型:字符串(可以设置多次)
¥Type: String (can be set multiple times)
启用在当前项目的已配置工作区的上下文中运行命令,同时通过仅运行此配置选项定义的工作区进行过滤。
¥Enable running a command in the context of the configured workspaces of the current project while filtering by running only the workspaces defined by this configuration option.
workspace
配置的有效值为:
¥Valid values for the workspace
config are either:
-
工作区名称
¥Workspace names
-
工作区目录的路径
¥Path to a workspace directory
-
父工作区目录的路径(将导致选择该文件夹中的所有工作区)
¥Path to a parent workspace directory (will result in selecting all workspaces within that folder)
为 npm init
命令设置时,可以将其设置为尚不存在的工作区的文件夹,以创建文件夹并将其设置为项目中的全新工作区。
¥When set for the npm init
command, this may be set to the folder of a workspace which does not yet exist, to create the folder and set it up as a brand new workspace within the project.
此值不会导出到子进程的环境中。
¥This value is not exported to the environment for child processes.
workspaces
-
默认值:null
¥Default: null
-
类型:空值或布尔值
¥Type: null or Boolean
设置为 true 可在所有已配置工作区的上下文中运行该命令。
¥Set to true to run the command in the context of all configured workspaces.
显式将此设置为 false 将导致像 install
这样的命令完全忽略工作区。未明确设置时:
¥Explicitly setting this to false will cause commands like install
to ignore workspaces altogether. When not set explicitly:
-
在
node_modules
树上运行的命令(安装、更新等)会将工作区链接到node_modules
文件夹。* 执行其他操作(测试、执行、发布等)的命令将在根项目上运行,除非在workspace
配置中指定了一个或多个工作区。¥Commands that operate on the
node_modules
tree (install, update, etc.) will link workspaces into thenode_modules
folder. - Commands that do other things (test, exec, publish, etc.) will operate on the root project, unless one or more workspaces are specified in theworkspace
config.
此值不会导出到子进程的环境中。
¥This value is not exported to the environment for child processes.
include-workspace-root
-
默认值:false
¥Default: false
-
类型:布尔值
¥Type: Boolean
为命令启用工作区时包括工作区根。
¥Include the workspace root when workspaces are enabled for a command.
当为 false 时,通过 workspace
配置指定单个工作区,或通过 workspaces
标志指定所有工作区,将导致 npm 仅在指定的工作区上运行,而不是在根项目上运行。
¥When false, specifying individual workspaces via the workspace
config, or all workspaces via the workspaces
flag, will cause npm to operate only on the specified workspaces, and not on the root project.
此值不会导出到子进程的环境中。
¥This value is not exported to the environment for child processes.
install-links
-
默认值:false
¥Default: false
-
类型:布尔值
¥Type: Boolean
设置文件时:协议依赖将作为常规依赖打包和安装,而不是创建符号链接。此选项对工作区没有影响。
¥When set file: protocol dependencies will be packed and installed as regular dependencies instead of creating a symlink. This option has no effect on workspaces.
也可以看看
¥See Also