web開發環境搭建 一、安裝 nvm--node版本管理工具 二、 安裝nrm -- NPM registry manager 三、進入項目目錄,安裝依賴

一、安裝 nvm--node版本管理工具

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

在配置文件(~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc)末尾添加下列內容:

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm

刷新配置:

bash: source ~/.bashrc
zsh: source ~/.zshrc
ksh: . ~/.profile

用法:

nvm install node         # "node" is an alias for the latest version
nvm install 6.14.4      # or 10.10.0, 8.9.1, etc
nvm ls-remote            # list available versions
nvm use node            # use the installed version
nvm run node --version    # run
nvm which 5.0          # get the path to the executable to where it was installed

安裝後,通過nvm ls查看:

二、 安裝nrm -- NPM registry manager

npm install -g nrm 

安裝完成後執行 nrm ls:

* npm ------- https://registry.npmjs.org/
  yarn ------ https://registry.yarnpkg.com
  tencent --- https://mirrors.cloud.tencent.com/npm/
  cnpm ------ http://r.cnpmjs.org/
  taobao ---- https://registry.npm.taobao.org/
  nj -------- https://registry.nodejitsu.com/
  skimdb ---- https://skimdb.npmjs.com/registry
Usage: nrm [options] [command]

  Commands:

    ls                                    List all the registries
    current                               Show current registry name
    use <registry>                        Change registry to registry
    add <registry> <url> [home]           Add one custom registry
    login <registry> [value]              Set authorize information for a registry with a base64 encoded string or username and pasword
      -a  --always-auth                     Set is always auth
      -u  --username <username>             Your user name for this registry
      -p  --password <password>             Your password for this registry
      -e  --email <email>                   Your email for this registry
    set-hosted-repo <registry> <value>    Set hosted npm repository for a custom registry to publish packages
    set-scope <scopeName> <value>         Associating a scope with a registry
    del-scope <scopeName>                 Remove a scope
    set <registryName>                    Set custom registry attribute
      -a  --attr <attr>                    Set custorm registry attribute
      -v  --value <value>                  Set custorm registry value
    del <registry>                        Delete one custom registry
    rename <registryName> <newName>       Set custom registry name
    home <registry> [browser]             Open the homepage of registry with optional browser
    publish [<tarball>|<folder>]          Publish package to current registry if current registry is a custom registry. The field 'repository' of current custom registry is required running this command. If you're not using custom registry, this command will run npm publish directly
      -t  --tag [tag]                        Add tag
      -a  --access <public|restricted>       Set access
      -o  --otp [otpcode]                    Set otpcode
      -dr --dry-run                          Set is dry run
    test [registry]                       Show the response time for one or all registries
    help                                  Print this help

  Options:

    -h  --help     output usage information
    -V  --version  output the version number

三、進入項目目錄,安裝依賴

npm i
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章