In some cases, you want to express the compatibility of your package with a host tool or library, while not necessarily doing a require of this host. This is usually referred to as a plugin. Notably, your module may be exposing a specific interface, expected and specified by the host documentation.
nvm-v//检查nvm是否安装成功Runningversion1.1.7.Usage:nvmarch:Showifnodeisrunningin32or64bitmode.nvminstall<version> [arch] : The version can be a node.js version or "latest"for the latest stable version.Optionallyspecifywhethertoinstallthe32or64bitversion (defaults tosystemarch).Set [arch] to "all" to install 32 AND 64 bit versions.Add--insecuretotheendofthiscommandtobypassSSLvalidationoftheremotedownloadserver.nvmlist [available] : List the node.js installations. Type "available" at the end to see what can be installed. Aliased as ls.nvmon:Enablenode.jsversionmanagement.nvmoff:Disablenode.jsversionmanagement.nvmproxy [url] : Set a proxy to use for downloads. Leave [url] blank to see the current proxy.Set [url] to "none" to remove the proxy.nvmnode_mirror [url] : Set the node mirror. Defaults to https://nodejs.org/dist/. Leave [url] blank to use default url.nvmnpm_mirror [url] : Set the npm mirror. Defaults to https://github.com/npm/cli/archive/. Leave [url] blank to default url.nvmuninstall<version>:Theversionmustbeaspecificversion.nvmuse [version] [arch] : Switch to use the specified version. Optionally specify 32/64bit architecture.nvmuse<arch>willcontinueusingtheselectedversion,butswitchto32/64bitmode.nvmroot [path] : Set the directory where nvm should store different versions of node.js.If<path>isnotset,thecurrentrootwillbedisplayed.nvmversion:DisplaysthecurrentrunningversionofnvmforWindows.Aliasedasv.
基本用法
安装包,查看包信息
# Dependency packagenpminstall<packageName>npminstall<packageName>-fnpminstall<packageName>--force# Dev dependency packagenpminstall--save-dev<packageName>npmupdate<packageName>npmviewreactnpmview的别名npminforeactnpmshowreactnpmvreact
# 1. Create your custom package project with package.json;# 2. Export your package in index.js;module.exports=customPackage;# 3. Login, input your NPM account username, password, emailnpmlogin# 4. Publishnpmpublish# 5. Updatenpmversionpatchnpmversionminornpmversionmajornpmpublish# 6. 撤销npm--forceunpublishnpm-event@1.0.1
NPM Link: Test packages before publish
# cd yx-node# Go to package directory, such as @daybyday/yx-node# Generate package linknpmlink# cd blog# Go to your test project which use your package# Add link to project package.jsonnpmlink@daybyday/yx-node# You can test it now.# Error: React Hooks Error: Hooks can only be called inside the body of a function component# Solve: 让组件库依赖测试项目的 react,这样就不会存在版本冲突的问题,如下cddemo/react-componentsnpmlink../test-component-project/node-modules/react# 重新build组件,在测试项目中 npm link 'react-components' (packageName)# unlinknpmunlink@daybyday/yx-node
The problem is with the spaces in URL(C:\Program Files). Try to install the nvm directly in C:/ or in other folder without spaces in the PATH.
发布 NPM 包版本时: npm ERR! 403 403 Forbidden - PUT * - [no_perms] Private mode enable, only admin can publish this module
registry 配置项被修改为非 npmjs, 需要重新设置为 npmjs
npmconfigsetregistryhttps://registry.npmjs.org
Git set custom registry when group is using cnpm
# Just only set @xx/xxxxxx for your group's components;npmconfigset"@xx:registry"https://npm.xxxxxx.net.cn:/# Reset default npm registrynpmconfigsetregistryhttps://registry.npmjs.org# Reset Taobao npm registrynpmconfigsetregistryhttps://registry.npm.taobao.org/
npm ERR! code E401 npm ERR! 401 Unauthorized - PUT https://xxx - [unauthorized] Login first