You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
file:///opt/WoRPG/Network/Protocol/Packet.js:1
import { load } from 'protobufjs';
^^^^
SyntaxError: The requested module 'protobufjs' does not provide an export named 'load'
at ModuleJob._instantiate (node:internal/modules/esm/module_job:132:21)
at async ModuleJob.run (node:internal/modules/esm/module_job:214:5)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
at async loadESM (node:internal/process/esm_loader:28:7)
at async handleMainPromise (node:internal/modules/run_main:113:12)
The require-import will also not work:
const Protobuf = require('protobufjs/light');
Result:
file:///opt/WoRPG/Network/Protocol/Packet.js:1
const Protobuf = require('protobufjs/light');
^
ReferenceError: require is not defined in ES module scope, you can use import instead
This file is being treated as an ES module because it has a '.js' file extension and '/opt/WoRPG/package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
at file:///opt/WoRPG/Network/Protocol/Packet.js:1:18
at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
at async loadESM (node:internal/process/esm_loader:28:7)
at async handleMainPromise (node:internal/modules/run_main:113:12)
Node.js v21.2.0
Following import will work, but has no accessible methods:
import * as Protobuf from 'protobufjs';
Protobuf.load('example.proto', function(err, root) {
// ...
});
Result:
TypeError: Protobuf.load is not a function
at new Packet (file:///opt/WoRPG/Network/Protocol/Packet.js:5:12)
at Client.onConnect (file:///opt/WoRPG/Network/Client.js:38:13)
at new Client (file:///opt/WoRPG/Network/Client.js:9:8)
at Server.<anonymous> (file:///opt/WoRPG/Network/Server.js:9:4)
at Server.emit (node:events:519:28)
at TCP.onconnection (node:net:2157:8)
The text was updated successfully, but these errors were encountered:
protobuf.js version:
7.2.5
I've tried to load the module, exactly described in the docs on following page:
https://www.npmjs.com/package/protobufjs#using-the-js-api
The require-import will also not work:
Result:
Following import will work, but has no accessible methods:
Result:
The text was updated successfully, but these errors were encountered: