#apt-get 卸载 sudo apt-get remove --purge npm sudo apt-get remove --purge nodejs sudo apt-get remove --purge nodejs-legacy sudo apt-get autoremove #手动删除 npm 相关目录 rm -r /usr/local/bin/npm rm -r /usr/local/lib/node-moudels find / -name npm rm -r /tmp/npm*
find command, I did not perform, but also did not remove the problem does not occur.
2. Install the latest node and npm
# apt-get 安装 nodejs sudo apt-get install nodejs sudo apt-get install nodejs-legacy
In the implementation of sudo apt-get install nodejs-legacy there is an error (like the kind of can not find the package), then apt-get update still not give up.
Download precompiled package to use https://nodejs.org/en/
bin directory under extracting file contains the node, npm commands, we can use the ln command to set the soft link:
$ ln -s /usr/software/nodejs/bin/npm /usr/local/bin/
$ ln -s /usr/software/nodejs/bin/node /usr/local/bin/
After performing node -v and npm -v version number can be found