Похожие чаты

I'Ve installed tone module by npm. And now want to import

it into a vanilla js file.
This is what I have tried:
import tone from 'tone'

But does not work!
Any solution!?

11 ответов

9 просмотров

import * as Tone from 'tone'

Did you install it globally

Import tone from "./path/to/file/node_modules/tone.js"

Reinstall the module locally

Y- Автор вопроса
david
import * as Tone from 'tone'

I already tried it as well but no difference Should i be using another bundler like common js or sth?

Y- Автор вопроса
J : Vaccinated 🇨🇦
Did you install it globally

Yep But that throws this: Uncaught TypeError: Failed to resolve module specifier "tone". Relative references must start with either "/", "./", or "../".

Y
Yep But that throws this: Uncaught TypeError: Fa...

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

Y- Автор вопроса
Artem Starikov
referring to modules by their names is a nodejs th...

By using paths, you mean import it locally like from node_modules folder? If so, i tried but throws not found error!

Y
By using paths, you mean import it locally like fr...

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

Похожие вопросы

Обсуждают сегодня

Всем привет, написал код ниже, но он выдает сегфолт, в чем причина? #include <stdio.h> #include <stdlib.h> #include <string.h> struct product { char *name; float price; };...
buzz базз
75
Hey, Oceaners 🌊 As we approach Phase 1 of the token merger, OCEAN and AGIX will migrate to FET starting July 1st! Here's a list of exchanges that have communicated their su...
KreigDK | Never DM first🌊
3
VIP 332 Quarterly XVS Buyback, Funds Allocation and New Tokenomics Summary This VIP outlines the protocol’s Quarterly Buyback and Funds Allocation strategy as per our Tokeno...
Venus Announcements
1
База данных не поможет. Шифрование не поможет. Какие там ещё варианты? Накидывайте.
КТ315
20
А табстоп это сообщение от окна или от элемента управления?
The Bird of Hermes
18
I love the passion, really do. I do think this is being blown way out of proportion. We are not deleting our Telegram or not allowing you to talk about anything you want, a...
Mike Herron
3
Did you guys see the latest tweet from TonGifts? 🚀
Mike
44
А как лучше конвертировать физический адрес в виртуальный при маппинге? В случае ядра у меня, например, direct mapping, первые 768МБ я как есть мапплю в higher half, а остальн...
Evg Resh
26
Hey, what is the best and maintained way of transpiling cpp to c? (As a need to support many different toolchains quickly and may not have a c++ support in the given toolch...
Meitar Reihan
11
Hey guys, did you see the latest announcement about $FUN? 🔥
Brian
21
Карта сайта