Hello All,
have just updated the npm versión of canvas and I am getting this error in execution.
Something has changed? (I am using typescript playcanvas migrating from 1.37.1 to 1.38.0)
TypeError: Class constructor ScriptType cannot be invoked without 'new’
at new scriptType (playcanvas.mjs:65478)
at ScriptComponent.create (playcanvas.mjs:53254)
at Cameras.createOrbitCamera (cameras.ts:36)
my code:
camera.script.create("orbitCamera", {
attributes: {
inertiaFactor: 0.2, // Override default of 0 (no inertia)
focusEntity: lookatEntity,
defaultEntity: defaultLookatEntity
}
});
Looks like you’re now using the newly introduced module build of the engine (playcanvas.mjs) instead of the ES5 build (playcanvas.js). Can you switch to the ES5 version to see if that works OK?
sorry for my unkowledge. How do you switch to the ES5 version?
Modifying the tsconfig.json?
I have:
{
“compilerOptions”: {
“target”: “es5”,
“module”: “es6”,
“outDir”: “./dist/”,
I am having the same error TypeError: Class constructor ScriptType cannot be invoked without 'new’. For now I’ve changed the package.json of playcanvas in my node_modules folder.
Hi, I also run into this issue, while I updated my project to the latest PlayCanvas version. Is there any solution in the meantime - did I overlook something? Only thing I did as usual is npm update
In your NPM project, go to node_modules folder, then the playcanvas folder. Open the package.json and change the module one to build/playcanvas.js (described above).
Hi @Ivolutio, thanks for your reply. I read the instructions in this thread, but isn’t it the case as (at least in my case) the node_modules folder is excluded from GIT and when someone else do npm install this error happens again?
You can also exclude a single library from your package.json from updating by locking its version. Do a stackoverflow search on this, you will find plenty of advice on how to do it.
Did you try this yet?
I am still having this same error with 1.39.0. I think it wants me to change the way I am adding script components with ‘new Class’… Is there some documentation for this?
If you’re brave, feel free to build playcanvas.mjs from that branch and verify it works for you. Otherwise, this will probably be merged and deployed this week as 1.39.1.