Tell npm cnpm npx nvm?

asl

npm stands Node Package Manager is the world's JavaScript package management tools, and is the default package management tool Node.js platform, the installation of nodejs time, npm will follow the installation together. It can be installed via npm, share, distribute the code, manage project dependencies.

Commonly used commands :

```

npm -v display version, check for correct installation npm
npm help to see detailed help for a command, such as install npm help
npm -g List View installed modules
npm show express view the installed modules details
npm cache clean - force the local cache to clear npm

npm init initialization
npm install xxx download package
npm uninstall xxx uninstall package
npm update xxx update package
npm outdated -g --depth = 0 To find packages need to be updated
`` `

Npm publish a package:

  1. Registration && query: https://www.npmjs.com
  2. log in:npm login
  3. Inquiries, confirm success:npm whoami
  4. Upload Package:npm publish
  5. Verify E-mail:npm adduser
  6. Change Source:npm config set registry http://registry.npmjs.org
  7. Update: modified version after npm publish

cnpm

cnpm Taobao mirror, can be seen as npm domestic version, download speed faster npm package.

Installation  npm install cnpm -g --registry=https://registry.npm.taobao.org.

npx

npm A command v5.2.0 introduced.

npx Rely on the bag will help you execute binaries, the introduction of this command is designed to enhance the developers to use command-line tools provided in the bag of experience.

The original need for a global installed package into the project directory installation.


npm install -g create-react-app

create-react-app my-app

new:

npx create-react-app my-app 

Temporary installation  create-react-app package, the command is completed  create-react-app will be deleted and will not appear in  global the next time execution, or re-install temporary.

NVM

node management tool

In development, sometimes there are requirements for version node, and sometimes need to switch to a specific node version to reproduce the problem and so on. When it came to this demand, we need the flexibility to switch node version, nvm is to solve the problems that arise, he can easily switch between multiple versions on the same node equipment.

nvm does not support Windows, but there are alternatives, that is, nvm-windows.

Installation NVM :

wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash 

After the installation is complete close the terminal, re-open the terminal and type nvm verify whether the installation was successful, when there is "Node Version Manager", indicating that it has successfully installed.

If you are prompted when a new terminal input nvm: command not found: nvm, there may be one of the following reasons:

Your system may lack a .bash_profile file, you can create a file (by command vi or vim), Open copy and paste the following code (installation nvm best 3 lines of code after the success of the terminal) go in, save, and then run again installation command;

export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

Note: If you installed oh my zsh, need to add more than .zshrc file configuration information (usually successful installation will automatically written to the bottom of this document).

If the above does not solve the problem, open your .bash_profile file and add the following code:
source ~/.bashrc, finished changing remember to save your changes.

Commonly used commands:

nvm ls-remote 列出全部可以安装的版本号

nvm install stable 安装当前最新的稳定版

nvm install v10.14.0 安装指定版本

nvm ls显示所有安装的版本

nvm current 查看当前版本

nvm use v10.14.0 切换node版本

nvm alias default v10.14.0 设置默认版本

Guess you like

Origin www.cnblogs.com/zhuangch/p/11668450.html