Tonejs / Tone.js

A Web Audio framework for making interactive music in the browser.
https://tonejs.github.io
MIT License
13.39k stars 976 forks source link

Unable to import tone #1089

Closed cryptozachary closed 2 years ago

cryptozachary commented 2 years ago

Hello All,

I've tried adding ./ or ../ to the import and it does not work. When adding the tone.js script directly to my html index file ,it works, however I do not have access to the tone object file in the window , which is what i really need. Pictures below 1 2 3

tambien commented 2 years ago

I would recommend using a javascript bundler such as webpack, rollup or parcel. Plain javascript has a syntax for importing modules, (more info here) but it comes with some caveats and complexities. So i find using a bundler to be the easiest and most compatible way to use Tone.js.

If you want to continue with the module syntax, then you'll need to follow the recommendation of the error and probably do something like import * as Tone from "./Tone.js" instead of what you current have.