I want to use node 20.9.0 and yarn 3.2.4.
If I do:
- mkdir test
- cd test
- yarn init
- yarn add protobufjs
I get the following error:
➤ YN0000: ┌ Resolution step
➤ YN0000: └ Completed in 0s 813ms
➤ YN0000: ┌ Fetch step
➤ YN0013: │ @protobufjs/utf8@npm:1.1.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ @types/node@npm:20.9.0 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ long@npm:5.2.3 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ protobufjs@npm:7.2.5 can't be found in the cache and will be fetched from the remote registry
➤ YN0013: │ undici-types@npm:5.26.5 can't be found in the cache and will be fetched from the remote registry
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0007: │ protobufjs@npm:7.2.5 must be built because it never has been before or the last one failed
➤ YN0009: │ protobufjs@npm:7.2.5 couldn't be built successfully (exit code 1, logs can be found here: /private/var/folders/7r/z2yvzrzx7_lg2h81285rsplr0000gp/T/xfs-6234630b/build.log)
➤ YN0000: └ Completed in 0s 474ms
➤ YN0000: Failed with errors in 1s 441ms
The build.log file is reporting...
# This file contains the result of Yarn building a package (protobufjs@npm:7.2.5)
# Script name: postinstall
node:internal/process/esm_loader:40
internalBinding('errors').triggerUncaughtException(
^
TypeError [Error]: [ERR_IMPORT_ASSERTION_TYPE_MISSING]: Module "XXXX/.yarn/unplugged/protobufjs-npm-7.2.5-3439c554a5/node_modules/protobufjs/package.json" needs an import assertion of type "json"
at load$1 (file:///XXXX/.pnp.loader.mjs:1455:17)
at nextLoad (node:internal/modules/esm/hooks:833:28)
at Hooks.load (node:internal/modules/esm/hooks:416:26)
at MessagePort.handleMessage (node:internal/modules/esm/worker:168:24)
at [nodejs.internal.kHybridDispatch] (node:internal/event_target:807:20)
at exports.emitMessage (node:internal/per_context/messageport:23:28) {
code: 'ERR_IMPORT_ASSERTION_TYPE_MISSING'
}
Node.js v20.9.0
Is this is known issue? Is there a solution?
The answer turns out to be that the bug was with yarn 3.2.4 itself, not with Cesium or Protobufjs. The issue preventing the build was apparently resolved with yarn 3.6.3. The steps will succeed with Node 20 and Yarn >= 3.6.3.