$ node -v
v8.10.0
$
$ npm -v
3.5.2
$
$ # 安装gulp-babel
$ npm install --save-dev gulp-babel
├── UNMET PEER DEPENDENCY @babel/core@^7.0.0
├─┬ gulp-babel@8.0.0
│ ├─┬ plugin-error@1.0.1
│ │ └── ansi-colors@1.1.0
│ └── replace-ext@1.0.1
└─┬ gulp-concat@2.6.1
└─┬ vinyl@2.2.1
└── replace-ext@1.0.1
npm WARN gulp-babel@8.0.0 requires a peer of @babel/core@^7.0.0 but none was installed.
npm WARN shugou@ No description
npm WARN shugou@ No repository field.
npm WARN shugou@ No license field.
$
$
$ # 无法安装以@开头的包名
$ npm install --save-dev @babel/core
npm ERR! Linux 4.15.0-122-generic
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "--save-dev" "@babel/core"
npm ERR! node v8.10.0
npm ERR! npm v3.5.2
npm ERR! code EMISSINGARG
npm ERR! typeerror Error: Missing required argument #1
npm ERR! typeerror at andLogAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:31:3)
npm ERR! typeerror at fetchPackageMetadata (/usr/share/npm/lib/fetch-package-metadata.js:51:22)
npm ERR! typeerror at resolveWithNewModule (/usr/share/npm/lib/install/deps.js:456:12)
npm ERR! typeerror at /usr/share/npm/lib/install/deps.js:457:7
npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror at /usr/share/npm/lib/fetch-package-metadata.js:37:12
npm ERR! typeerror at addRequestedAndFinish (/usr/share/npm/lib/fetch-package-metadata.js:82:5)
npm ERR! typeerror at returnAndAddMetadata (/usr/share/npm/lib/fetch-package-metadata.js:117:7)
npm ERR! typeerror at pickVersionFromRegistryDocument (/usr/share/npm/lib/fetch-package-metadata.js:134:20)
npm ERR! typeerror at /usr/share/npm/node_modules/iferr/index.js:13:50
npm ERR! typeerror This is an error with npm itself. Please report this error at:
npm ERR! typeerror <http://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
$
使用淘宝npm镜像
ps: 也可升级npm版本
$ sudo npm install -g cnpm --registry=https://registry.npm.taobao.org
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
/usr/local/bin/cnpm -> /usr/local/lib/node_modules/cnpm/bin/cnpm
/usr/local/lib
├── ansi-regex@2.1.1
├── aproba@2.0.0
...
$
$ cnpm -v
cnpm@6.1.1 (/usr/local/lib/node_modules/cnpm/lib/parse_argv.js)
npm@6.14.11 (/usr/local/lib/node_modules/cnpm/node_modules/npm/lib/npm.js)
node@8.10.0 (/usr/bin/node)
npminstall@3.28.0 (/usr/local/lib/node_modules/cnpm/node_modules/npminstall/lib/index.js)
prefix=/usr/local
linux x64 4.15.0-122-generic
registry=https://r.npm.taobao.org
$
测试
$ cnpm install --save-dev gulp-babel @babel/core @babel/preset-env
✔ Installed 3 packages
✔ Linked 168 latest versions
✔ Run 0 scripts
Recently updated (since 2021-02-18): 49 packages (detail see file /home/gfk/workspace/healthworker/shugou/node_modules/.recently_updates.txt)
Today:
→ @babel/preset-env@7.13.5 › babel-plugin-polyfill-corejs2@^0.1.4(0.1.6) (02:37:25)
✔ All packages installed (173 packages installed from npm registry, used 3s(network 3s), speed 1014.67kB/s, json 171(557.04kB), tarball 2.24MB)
$