问题描述
我尝试运行此命令 npx create-react-app my-app
并收到此错误
I tried to run this command npx create-react-app my-app
and got this error
error @typescript-eslint/[email protected]: The engine "node" is incompatible with this module. Expected version "^10.12.0 || >=12.0.0". Got "11.13.0"
error Found incompatible module.
奇怪的是我使用了 node 版本 15.0.1(最新)和 yarn 版本 1.22.10(最新)以及 npx 使用的版本 Got "11.13.0"
不存在在我的机器上.
The weird thing is I used node version 15.0.1 (latest) and yarn version 1.22.10 (latest) and the version that npx used Got "11.13.0"
which does not exist on my machine.
有人遇到过这个问题吗?请帮忙,非常感谢.
Anybody face this problem ? Please help, many thanks in advance.
推荐答案
在Windows上情况可能有所不同,但在类UNIX操作系统(包括macOS)上,你可以找到节点的路径
由 npx
执行:
The situation may be different on Windows, but on UNIX-like operating systems (including macOS), you can find the path to the node
being executed by npx
with:
/usr/bin/env node -p process.execPath
这是因为 npx
文件以 #!/usr/bin/env node
开头.因此,您可以使用 /usr/bin/env node
来执行 npx
将执行的相同 node
.
This is because the npx
file starts with #!/usr/bin/env node
. So you can use /usr/bin/env node
to execute the same node
that npx
will.
-p
表示打印值";process.execPath
是可执行文件的路径.
-p
means "print the value" and process.execPath
is the path to the executable.
which
将报告别名,这意味着它将报告您将在 shell 中看到的 node
可执行文件.这不是 npx
将使用的,这似乎可以解释为什么 npx
可能使用与您预期不同的 Node.js 版本.
which
will report aliases, which means that it will report the node
executable you will see in your shell. That's not what npx
will use, and that seems a likely possibility to explain why npx
might use a different Node.js version than you expect.
$ alias node=echo
$ node foo
foo
$ which node
node: aliased to echo
$ /usr/bin/env node -p process.execPath
/Users/trott/.nvm/versions/node/v15.0.1/bin/node
$
这篇关于npx 运行在我的机器上不存在的节点版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!