简体   繁体   English

如何修复 cb.apply 不是函数,npx + preact-cli

[英]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:我正在使用以下版本:

  • node v15.0.1节点 v15.0.1
  • npm 7.0.3 npm 7.0.3
  • npx 10.2.2 npx 10.2.2

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.

相关问题 Ubuntu 上的 Nuxt 3:cb.apply 不是函数 - Nuxt 3 on Ubuntu : cb.apply is not a function npm 错误。 cb.apply 不是 function - npm ERR! cb.apply is not a function npm 错误。 cb.apply 在执行时不是 function > npm install @angular/cli@latest - npm ERR! cb.apply is not a function while doing > npm install @angular/cli@latest Gitbook-cli安装报错TypeError: cb.apply is not a function inside graceful-fs - Gitbook-cli install error TypeError: cb.apply is not a function inside graceful-fs 将 sass 添加到项目中 - 安装不起作用 - cb.apply 不是 function - Adding sass to the project - installation not working - cb.apply is not a function npm 错误。 cb.apply 不是 function(基本操作系统) - npm ERR! cb.apply is not a function (Elementary OS) npm 错误。 cb.apply 不是 NPM Nodist 中的 function - npm ERR! cb.apply is not a function in NPM Nodist 错误 cb.apply 不是 Node Express 项目中的函数 [尝试安装软件包时] -- - ERROR cb.apply is not a function [while trying to install packages] in Node Express project -- preact-cli "^3.4.2" 创建的默认项目没有运行 - The default project created by preact-cli "^3.4.2" doesn't run 如何修复比较密码时出现的“TypeError: cb is not a function”错误 - How to fix "TypeError: cb is not a function" error for comparing passwords
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM