I'm trying to create a new project with 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
- npm 7.0.3
- npx 10.2.2
At the time of this writing, the latest version of preact-cli published on npm is 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
. Ok, so I looked at that, it's inside of a function called statFix
. Which apparently fixes some incompatibilities with "older versions of Node". Googling for statFix
let me to this site. They say to simply comment out the usages of the statFix function. 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. 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).
Is it possible to use preact-cli with a version of node greater than v14?
UPDATE: I went through the pain of uninstalling node v15 and instead installing v14 LTS. The problem stays the same. It doesn't seem to be directly related to v15. I've also updated the question title accordingly.