简体   繁体   English

使用 nvm 在 ubuntu 21.10 上安装节点 16.3.0 后,npx 无法正常工作

[英]npx is not working after installing node 16.3.0 on ubuntu 21.10 with nvm

I installed node js using nvm first I installed version 17.1.0 I had some problems with node-gyp, so I downgraded to 16.3.0 (current lts).我首先使用 nvm 安装了 node js 我安装了 17.1.0 版本我在 node-gyp 上遇到了一些问题,所以我降级到了 16.3.0(当前 lts)。 but every script I am runing using npx causeing me an error但是我使用 npx 运行的每个脚本都会导致我出错

spawn <package npx need to run> ENOENT

If I am installing the package globaly it will work only in the same terminal session如果我在全球范围内安装 package 它将仅在同一终端 session 中工作

I understand this may not be the best solution but I have been having problems with nvm and versions not actually switching So I would start by looking at your current node version我知道这可能不是最好的解决方案,但我遇到了 nvm 问题,并且版本实际上没有切换所以我先看看你当前的节点版本

node -v

And check your npx version with并检查您的 npx 版本

npx -v

Anything above node 5.2 should have npx already installed but on the off chance that it isn't you can install it with节点 5.2 以上的任何东西都应该已经安装了 npx,但如果不是,你可以安装它

npm install -g npx

If this is all installed, theoretically it should all work but I understand you are having issues.如果这一切都已安装,理论上它应该都可以工作,但我知道你遇到了问题。 This is not an ideal solution, but you could这不是一个理想的解决方案,但你可以

npm i <package-name>

npm run <package-name>

Hopefully this at least allows you to continue working while finding out why npx isn't working on your machine.希望这至少可以让您继续工作,同时找出 npx 无法在您的机器上工作的原因。

Another npm version manager alternative is n if you'd like to check them out and see if you have any better luck installing and changing node versions https://www.npmjs.com/package/n另一个 npm 版本管理器替代方案是 n 如果您想检查它们,看看您是否有更好的运气安装和更改节点版本https://www.npmjs.com/package/n

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM