nvm npm不是内部命令
npm
or the Node Package Manager, is one of the most used tools for any Node.js developer. Here's a list of the most common commands you'll use when working with npm
.
npm
或Node Package Manager是Node.js开发人员最常用的工具之一。 这是使用npm
时将使用的最常见命令的列表。
安装package.json
依赖项 (Install package.json
dependencies)
npm install
速记 (Shorthand)
# install
npm i <package>
# uninstall
npm un <package>
# update
npm up <package>
标志 (Flags)
-S
is the same as --save
, and -D
is the same as --save-dev
.
-S
与--save
相同, -D
与--save-dev
相同。
列出全局安装的软件包 (List globally installed packages)
npm list -g --depth=0
卸载全局软件包 (Uninstall global package)
npm -g uninstall <name>
在Windows上升级npm
(Upgrade npm
on Windows)
npm-windows-upgrade
更新全局软件包 (Update global packages)
To see which packages need updating, use:
要查看哪些软件包需要更新,请使用:
npm outdated -g --depth=0
To update global packages individually you can use:
要单独更新全局软件包,可以使用:
npm update -g <package> <package> <package>
列出要运行的可用脚本 (list available scripts to run)
npm run
更新npm
(Update npm
)
npm install -g npm@latest
# using windows? Then use
npm-windows-upgrade
安装版本 (Installed version)
npm list # for local packages
节点版本管理器nvm
(Node Version Manager nvm
)
nvm
makes it easy to switch between different versions of Node.js. Read more about it on the project's GitHub page.
nvm
可以轻松地在不同版本的Node.js之间切换。 在该项目的GitHub页面上阅读有关它的更多信息。
Once you have nvm
installed, if you want to install the latest version of Node v12 just run:
安装nvm
,如果要安装最新版本的Node v12,请运行:
nvm install 12
If you have multiple versions of Node.js installed on your workspace, you can switch to a specific version by writing:
如果您的工作空间上安装了多个版本的Node.js,则可以通过以下方式切换到特定版本:
nvm use 10.19.0
将节点版本设为默认 (Make a Node version default)
In order to set a default version of Node for your workspace, just type:
为了为您的工作区设置默认版本的Node,只需键入:
nvm alias default 12
Where the latest version of 12 is the version you want to be used by default.
其中最新版本的12是默认情况下要使用的版本。
更新npm
(Update npm
)
If you use Node installed through nvm
, it's good practice to update your version of npm
with this command:
如果您使用通过nvm
安装的nvm
,则最好使用以下命令来更新npm
版本:
nvm install-latest-npm
更多信息: (More information:)
翻译自: https://www.freecodecamp.org/news/npm-cheat-sheet-most-common-commands-and-nvm/
nvm npm不是内部命令