作为 root,我在我的 OpenSUSE Leap 15.2 linux 服务器上删除了 /usr/local/bin 和 /usr/local/lib 中的一些目录,以清理一些 nodejs 模块。然后我卸载nodejs
并npm
使用 Zypper ( zypper remove nodejs npm
)。我删除了根目录中的“.npm”目录。我find
从 / 为 'node_modules' 做了一个,但没有找到。之后,我安装了“nodejs”和“npm”(zypper install nodejs npm
),它报告它成功安装了它们。但是当我执行“npm -v”时,它会以/usr/local/bin/npm: No such file or directory
. 我多次尝试卸载/重新安装这些软件包,但 npm 一直因此错误而失败。我有下面的输出。任何帮助是极大的赞赏。
The following 2 recommended packages were automatically selected:
nodejs12-devel npm12
4 new packages to install.
Overall download size: 11.1 MiB. Already cached: 0 B. After the operation, additional 48.0 MiB will be used.
Continue? [y/n/v/...? shows all options] (y): y
Retrieving package nodejs-common-2.0-lp152.3.2.noarch (1/4), 8.1 KiB ( 230 B unpacked)
Retrieving: nodejs-common-2.0-lp152.3.2.noarch.rpm ...............................................................................................[done (5.2 KiB/s)]
Retrieving package nodejs12-12.18.2-lp152.3.3.1.x86_64 (2/4), 7.3 MiB ( 27.9 MiB unpacked)
Retrieving: nodejs12-12.18.2-lp152.3.3.1.x86_64.rpm ..............................................................................................[done (6.2 MiB/s)]
Retrieving package nodejs12-devel-12.18.2-lp152.3.3.1.x86_64 (3/4), 170.5 KiB (802.1 KiB unpacked)
Retrieving: nodejs12-devel-12.18.2-lp152.3.3.1.x86_64.rpm ........................................................................................[done (2.4 KiB/s)]
Retrieving package npm12-12.18.2-lp152.3.3.1.x86_64 (4/4), 3.6 MiB ( 19.3 MiB unpacked)
Retrieving: npm12-12.18.2-lp152.3.3.1.x86_64.rpm .............................................................................................................[done]
Checking for file conflicts: .................................................................................................................................[done]
(1/4) Installing: nodejs-common-2.0-lp152.3.2.noarch .........................................................................................................[done]
(2/4) Installing: nodejs12-12.18.2-lp152.3.3.1.x86_64 ........................................................................................................[done]
Additional rpm output:
update-alternatives: using /usr/bin/node12 to provide /usr/bin/node-default (node-default) in auto mode
(3/4) Installing: nodejs12-devel-12.18.2-lp152.3.3.1.x86_64 ..................................................................................................[done]
(4/4) Installing: npm12-12.18.2-lp152.3.3.1.x86_64 ...........................................................................................................[done]
Additional rpm output:
update-alternatives: using /usr/bin/npm12 to provide /usr/bin/npm-default (npm-default) in auto mode
update-alternatives: using /usr/bin/npx12 to provide /usr/bin/npx-default (npx-default) in auto mode
host1:/ # which npm
/usr/bin/npm
host1:/ # npm -v
-bash: /usr/local/bin/npm: No such file or directory
host1:/ # which node
/usr/bin/node
host1:/ # node -v
v12.18.2
host1:/ #