preface

To do a good job, he must sharpen his tools.

NVM installs the management node

// Uninstall the original Node before installing the NVM. // Download address: https://github.com/coreybutler/nvm-windows/releases NVM / / will prompt NVW under the relevant command NVM ls / / view the installed version of the node also NVM NVM list are install VXX // Install the node of the vXX version eg: NVM install v13.9.0 NVM uninstall vXX // Uninstall the node of the vXX version eg: NVM uninstall v13.9.0 NVM use XXX // Root: D:\ NVM path: D:\ NVM \nodejs node_mirror: https://npm.taobao.org/mirrors/node/ npm_mirror: https://npm.taobao.org/mirrors/npm/ or set "NVMW_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node" set "NVMW_NPMJS_COM_MIRROR=https://npm.taobao.org/mirrors/npm I told me," when installing new version node taobao NPM source basic cannot work, download error, the old version.Copy the code

Package manager installation mode

  • npm
    NPM install NPM -g // Upgrade to the latest versionCopy the code
  • yarn
    You can download the. Msi file. NPM install yarn -g Automatically configure environment variables during installationCopy the code
  • pnpm
    NPM add PNPM -g // View the source PNPM add PNPM -g // Upgrade to the new versionCopy the code

The source

  • npm
    NPM config get registry / / view source NPM config set registry https://registry.npmmirror.com/cut/taobao sourceCopy the code
  • yarn
    Yarn config get registry / / view source yarn config set registry https://registry.npmmirror.com/cut/taobao source yarn config set Electron_mirror HTTP: / / https://npm.taobao.org/mirrors/electron/ / / for a specific package yarn config set sass - binary - site http://npm.taobao.org/mirrors/node-sassCopy the code
  • pnpm
    PNPM config get registry / / view source PNPM config set registry https://registry.npmmirror.com/cut/taobao sourceCopy the code

The installation

  • npm
    NPM install package name or NPM install package name -s // Write dependencies NPM install package name -d // Write devDependencies NPM install package name -g // Global NPM Install Package name@Version number // Add the version numberCopy the code
  • yarn
    Yarn add Package name // By default, write dependencies yarn add package name -d // By default, write devDependencies yarn Global add package name // Global YARN add package name. version number // Add version numberCopy the code
  • pnpm
    PNPM can be installed using Install Add, Install is also short for I PNPM add package name // By default, write dependencies PNPM add package name -d // by default, write devDependencies PNPM add -g package name // global PNPM add package name @ version number // Add the version numberCopy the code

To view

  • npm
    NPM list --depth 0 // Viewing the packages in the project depth indicates the depth. This parameter is optional. NPM list -g --depth 0 // Viewing the global packages depth indicates the depthCopy the code
  • yarn
    Yarn list -r --global // Viewing global packages Depth indicates the depth. Optional parameters YARN list // Viewing packages in a project Depth indicates the depth. Optional parameters include dependenciesCopy the code
  • pnpm
    PNPM list -r // View the package depth depth indicates the package depth. This parameter is optional. PNPM list -r // View the package depth in the projectCopy the code

remove

  • npm
    NPM uninstall Package name // Remove package NPM uninstall package name -g // Remove global packageCopy the code
  • yarn
    Yarn Remove Package name // Remove package yarn Global Remove Package name // Remove global packageCopy the code
  • pnpm
    PNPM remove package name PNPM remove package name --global PNPM remove package name -d devDependenciesCopy the code

update

  • npm
    NPM update Package name // Update package name NPM update package -g // Update global packageCopy the code
  • yarn
    Yarn Upgrade package name // Update package Name of yarn Global upgrade package // Update the global packageCopy the code
  • pnpm
    PNPM up --latest // Update all dependencies. Json PNPM upgrade package name --global // Update global packageCopy the code

Clear the cache

  • npm
    npm cache clean --force
    Copy the code
  • yarn
    yarn cache clean
    Copy the code

Run the task

  • npm
    npm run
    Copy the code
  • yarn
    yarn run
    Copy the code
  • pnpm
    pnpm run
    Copy the code

Modify global installation and cache locations

  • npm
    NPM config list // View the configuration information NPM config get prefix // View the global installation location NPM config set prefix New path // Change the global installation location NPM config get cache NPM config set new cache path // Change the cache locationCopy the code
  • yarn
    Yarn config // View configuration information yarn config get global-folder or yarn Global dir // View the global installation location yarn config set global-folder New path Yarn config get cache-folder // Check the cache location yarn config set cache-folder New path // Change the cache location yarn Global bin // Check the current YARN The bin location ofCopy the code
  • npm
    PNPM config list // Check the configuration information. PNPM config get prefix // Check the global installation location. PNPM config set prefix New path. // Change the global installation location PNPM config set New cache path // Change the cache locationCopy the code

Q&A

  • If you encounter “XXX cannot load file xxx.ps1 because scripts are not allowed to run on this system. For more information, please refer to the about_Execution_Policies https:/go.microsoft.com/fwlink/?LinkID=135170.” The problem can be solved by removing this PS1. Because it was caused by a lack of access, we can give him access to fix it
get-ExecutionPolicy // Restricted
Set-ExecutionPolicy -Scope CurrentUser
RemoteSigned
get-ExecutionPolicy // RemoteSigned
Copy the code
  • If the package console of yarn global installation cannot be found, you can use yarn global dir to view the location of the global installation and add the complete bin path to the system environment variable, for example, E: MyApp\ yarn \global\node_modules.bin