在这篇文章中,我尝试了一些建议的方法。
1) npm更新-g npm
npm update -g npm
/usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js
/usr/bin/npx -> /usr/lib/node_modules/npm/bin/npx-cli.js
- asap@2.0.5 node_modules/npm/node_modules/asap
- fstream@1.0.10 node_modules/npm/node_modules/fstream
- balanced-match@0.4.2 node_modules/npm/node_modules/fstream-npm/node_modules/fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/balanced-match
- concat-map@0.0.1 node_modules/npm/node_modules/fstream-npm/node_modules/fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/node_modules/concat-map
- brace-expansion@1.1.6 node_modules/npm/node_modules/fstream-npm/node_modules/fstream-ignore/node_modules/minimatch/node_modules/brace-expansion
...
- realize-package-specifier@3.0.3 node_modules/npm/node_modules/realize-package-specifier
/usr/lib
`-- npm@5.5.1 但是,当我尝试使用npm --version时,它的错误消息失败了:
# npm --version
module.js:471
throw err;
^
Error: Cannot find module 'process-nextick-args'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/lib/node_modules/npm/node_modules/readable-stream/lib/_stream_readable.js:26:23)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)2)卷曲https://www.npmjs.com/install.sh _ sh
# curl https://www.npmjs.com/install.sh | sh
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6255 100 6255 0 0 6728 0 --:--:-- --:--:-- --:--:-- 6725
tar=/bin/tar
version:
tar (GNU tar) 1.28
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by John Gilmore and Jay Fenlason.
install npm@latest
fetching: https://registry.npmjs.org/npm/-/npm-5.5.1.tgz
module.js:471
throw err;
^
Error: Cannot find module '/tmp/npm.18/package/bin/read-package-json.js'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:383:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:496:3
removed 266 packages in 5.41s
/usr/bin/npx -> /usr/lib/node_modules/npm/bin/npx-cli.js
/usr/bin/npm -> /usr/lib/node_modules/npm/bin/npm-cli.js
+ npm@5.5.1
added 1 package in 1.642s
It worked但是npm命令在系统中不可用。文件似乎根本没有安装。
# ls -l /usr/bin/npm
lrwxrwxrwx 1 root root 38 Nov 3 01:26 /usr/bin/npm -> ../lib/node_modules/npm/bin/npm-cli.js
# ls /usr/lib/node_modules/npm/bin/npm-cli.js
ls: cannot access '/usr/lib/node_modules/npm/bin/npm-cli.js': No such file or directory我的running正在码头集装箱里运行。下面是dockerfile:
FROM ubuntu:16.04
RUN apt-get update --fix-missing && apt-get install -y vim libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++
RUN curl -sL https://deb.nodesource.com/setup_6.x | bash -
RUN apt-get install -y nodejs
# RUN apt-get install -y npm
RUN update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10那么,升级npm的最新方式是什么呢?
发布于 2017-11-03 02:17:52
您可以为此使用Node (NVM)。尝试使用以下命令。我在使用节点时遇到了很多问题,但是下面的内容总是有效的。
//This will install npm v5.4, this might break if you're using node 4.5 and 4.6
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash
//To uninstall a node version
nvm uninstall <current version>
nvm install 8.5.0
nvm use 8.5.0
//check with
node -v如果您使用它与码头,最简单的方法是直接使用节点码头从码头枢纽
例:
第一次拉动:
docker pull node:6.11.5-wheezy并将以下内容添加到docker文件中:
FROM node:6.11.5-wheezyhttps://stackoverflow.com/questions/47087100
复制相似问题