ThatOpen / engine_web-ifc

Reading and writing IFC files with Javascript, at native speeds.
https://thatopen.github.io/engine_web-ifc/demo
Mozilla Public License 2.0
585 stars 176 forks source link

[Bug]: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './web-ifc-api' is not defined by "exports" in D:\App\Backend\node_modules\web-ifc\package.json #785

Closed lukinoe closed 3 months ago

lukinoe commented 3 months ago

What happened?

It seems that the "web-ifc" package is attempting to access the "web-ifc-api" subpath, but this subpath is not defined in the "exports" field of the "web-ifc" package's package.json file.

Version

0.0.54

What browsers are you seeing the problem on?

No response

Relevant log output

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './web-ifc-api' is not defined by "exports" in D:\App\Backend\node_modules\web-ifc\package.json
?[90m    at new NodeError (node:internal/errors:387:5)?[39m
?[90m    at throwExportsNotFound (node:internal/modules/esm/resolve:464:9)?[39m
?[90m    at packageExportsResolve (node:internal/modules/esm/resolve:748:3)?[39m
?[90m    at resolveExports (node:internal/modules/cjs/loader:493:36)?[39m
?[90m    at Function.Module._findPath (node:internal/modules/cjs/loader:533:31)?[39m
?[90m    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:942:27)?[39m
?[90m    at Function.Module._load (node:internal/modules/cjs/loader:804:27)?[39m
?[90m    at Module.require (node:internal/modules/cjs/loader:1028:19)?[39m
?[90m    at require (node:internal/modules/cjs/helpers:102:18)?[39m
    at Object.<anonymous> ?[90m(D:\LW-App\Backend\?[39mifc_read.js:1:16?[90m)?[39m {
  code: ?[32m'ERR_PACKAGE_PATH_NOT_EXPORTED'?[39m
}

Anything else?

The error occurs when starting a clean new project when calling import.

node.js: v. 16.17.0 Windows Operating System

lukinoe commented 3 months ago

Code executed:

const WebIFC = require("web-ifc/web-ifc-api");

// initialize the API const ifcApi = new WebIFC.IfcAPI();

// initialize the library ifcApi.Init();

// Read the IFC file fs.readFile(ifcFilePath, 'utf8', (err, data) => { if (err) { console.error('Error reading the file:', err); return; }

// Parse the IFC data const modelID = ifcAPI.OpenModel(data);

// Extract hierarchy const hierarchy = extractHierarchy(modelID);

console.log(hierarchy);

// Close the model to free resources ifcAPI.CloseModel(modelID); });

RyugaRyuzaki commented 3 months ago

hi @lukinoe try "node --no-experimental-fetch src/server.js"

lukinoe commented 3 months ago

hi @RyugaRyuzaki, why is that necessary?

I think the standard example code from the tutorial in a plain new project should be working ...

lukinoe commented 3 months ago

also "node --no-experimental-fetch src/server.js" is not working for me

lukinoe commented 3 months ago

it worked by calling:

const WebIFC = require("web-ifc");

instead of const WebIFC = require("web-ifc/web-ifc-api");

in node.