[英]how to fix cb.apply is not a function, npx + preact-cli
I'm trying to create a new project with preact-cli
:我正在尝试使用
preact-cli
创建一个新项目:
npx preact-cli create typescript temp
It fails with the error message:它失败并显示错误消息:
npm ERR! cb.apply is not a function
I'm using the following versions:我正在使用以下版本:
At the time of this writing, the latest version of preact-cli published on npm is 3.0.3.在撰写本文时,npm 上发布的 preact-cli 的最新版本是 3.0.3。
My attempts to fix this:我试图解决这个问题:
The error message points to a logfile and there the error is quite prominent:错误消息指向一个日志文件,错误非常突出:
...
7 http fetch GET 304 https://registry.npmjs.org/preact-cli 147ms (from cache)
8 silly pacote tag manifest for preact-cli@latest fetched in 167ms
9 verbose stack TypeError: cb.apply is not a function
9 verbose stack at /home/lhk/.npm-global/lib/node_modules/npx/node_modules/npm/node_modules/graceful-fs/polyfills.js:287:18
9 verbose stack at FSReqCallback.oncomplete (node:fs:184:5)
Apparently this is an error in graceful-fs/polyfills.js
.显然,这是
graceful-fs/polyfills.js
的错误。 Ok, so I looked at that, it's inside of a function called statFix
.好的,所以我看了看,它在一个名为
statFix
的函数statFix
。 Which apparently fixes some incompatibilities with "older versions of Node".这显然修复了与“旧版本的 Node”的一些不兼容性。 Googling for
statFix
let me to this site .谷歌搜索
statFix
让我到这个网站。 They say to simply comment out the usages of the statFix function.他们说简单地注释掉 statFix 函数的用法。 I tried it, but the error stays.
我试过了,但错误仍然存在。
So I thought I'd instead go for npm install -g preact-cli
and see if that works better.所以我想我应该去
npm install -g preact-cli
看看是否效果更好。 There's a long list of warnings and deprecated messages.有一长串警告和已弃用的消息。 One of the warnings is this:
警告之一是这样的:
npm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
That looks like the likely offender to me.在我看来,这很可能是冒犯者。 It even says explicitly that it will break on node v14+ (I'm on v15).
它甚至明确表示它将在节点 v14+ 上中断(我在 v15 上)。
Is it possible to use preact-cli with a version of node greater than v14?是否可以将 preact-cli 与高于 v14 的节点版本一起使用?
UPDATE: I went through the pain of uninstalling node v15 and instead installing v14 LTS.更新:我经历了卸载 node v15 而不是安装 v14 LTS 的痛苦。 The problem stays the same.
问题保持不变。 It doesn't seem to be directly related to v15.
它似乎与 v15 没有直接关系。 I've also updated the question title accordingly.
我也相应地更新了问题标题。
Preact 接受 Node v12 作为最新版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.