I have some Problems when trying to import web-ifc-three in my nodeJs Project.
I'm trying to load an ifcModel in my REST Service.
It's just a simple example, but everytime I try to start my backend it throws the following error:
import * as WebIFC from 'web-ifc';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at internalCompileFunction (node:internal/vm:73:18)
at wrapSafe (node:internal/modules/cjs/loader:1176:20)
at Module._compile (node:internal/modules/cjs/loader:1218:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at ModuleWrap. (node:internal/modules/esm/translators:169:29)
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
Node.js v18.15.0
My example-code:
import express from "express";
import IFCLoader from "web-ifc-three";
Would be good to see the whole project (a github link?), but you might try to edit package.json file and add "type": "module"
..." main": "app.js", "type": "module", "scripts": { ...
Hey everyone,
I have some Problems when trying to import web-ifc-three in my nodeJs Project. I'm trying to load an ifcModel in my REST Service. It's just a simple example, but everytime I try to start my backend it throws the following error:
import * as WebIFC from 'web-ifc'; ^^^^^^ SyntaxError: Cannot use import statement outside a module at internalCompileFunction (node:internal/vm:73:18) at wrapSafe (node:internal/modules/cjs/loader:1176:20) at Module._compile (node:internal/modules/cjs/loader:1218:27) at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) at Module.load (node:internal/modules/cjs/loader:1117:32) at Module._load (node:internal/modules/cjs/loader:958:12) at ModuleWrap. (node:internal/modules/esm/translators:169:29)
at ModuleJob.run (node:internal/modules/esm/module_job:194:25)
Node.js v18.15.0
My example-code:
import express from "express"; import IFCLoader from "web-ifc-three";
const app = express();
app.get("/process-ifc", async (req, res) => { const ifcLoader = new IFCLoader.IFCLoader(); ifcLoader.ifcManager ifcLoader.load('../rst_basic_sample_project.ifc', (ifcModel) => { console.log('Model loaded'); }); });
app.listen(3000, () => { console.log("Server listening at http://localhost:3000"); });
package.json:
{ "name": "ifc-convert", "version": "0.0.1", "description": "", "main": "index.js", "type": "module", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", "url": "..." }, "author": "...", "license": "ISC", "bugs": { "url": "..." }, "homepage": "...", "dependencies": { "express": "^4.18.2", "web-ifc-three": "^0.0.125" } }