Dop4miN
Dop4miN

Reputation: 349

"Cannot use import statement outside a module" after installing babylonjs using npm

I've been trying to install babylonjs via npm. I've set up a new project and started with npm init. After that I installed babylonjs with npm install babylonjs --save according to their documentation. Now I created a JavaScript file to import their module using import * as BABYLON from 'babylonjs';. When I open the console it throws me this error: Uncaught SyntaxError: Cannot use import statement outside a module.

Since I'm relatively new to it I'm not quite sure if I'm missing an important step. I don't want to use their CDN, because I won't have access to the internet all the time.

Thanks in advance!

Upvotes: 1

Views: 773

Answers (1)

Raanan W
Raanan W

Reputation: 1295

I would recommend using the es6 packages, which fit better when using es6-style imports.

Here is the documentation:

https://doc.babylonjs.com/features/es6_support

Upvotes: 1

Related Questions