it into a vanilla js file.
This is what I have tried:
import tone from 'tone'
But does not work!
Any solution!?
import * as Tone from 'tone'
Did you install it globally
Import tone from "./path/to/file/node_modules/tone.js"
Reinstall the module locally
To refer to it easily
I already tried it as well but no difference Should i be using another bundler like common js or sth?
Yep But that throws this: Uncaught TypeError: Failed to resolve module specifier "tone". Relative references must start with either "/", "./", or "../".
referring to modules by their names is a nodejs thing, with native es modules in browsers you can only use paths. also it's likely that the module you're trying to import is not written with browser es modules in mind, so you better use a bundler
By using paths, you mean import it locally like from node_modules folder? If so, i tried but throws not found error!
use a bundler, e.g. webpack or parcel. I'm 99% sure you're trying to use a module that uses Node.js's module system which is incompatible with browsers' pure ES module system
Обсуждают сегодня