Tonejs / Tone.js

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

Cannot find module `tone/build/esm/core/Global` #973

Closed lucpotage closed 2 years ago

lucpotage commented 3 years ago

I tried to use Tone.js on a new Nuxt 3 project. Unfortunately, I get the following error:

Cannot find module '/.../node_modules/tone/build/esm/core/Global' imported from /.../node_modules/tone/build/esm/index.js

I import Tone this way:

import * as Tone from 'tone'

Also tested this way:

import * as Tone from 'tone/build/esm/index.js'

I tried with the latest version and the next version without success. Any idea of what could be wrong?

dirkk0 commented 3 years ago

I just checked - for some reason I needed to re-install with npm init tone but import * as Tone from 'tone' works for me in a vanilla JS project.

tambien commented 3 years ago

Try also installing tone@next which changes the browser entry point (#914) and may also fix this issue.

lucpotage commented 2 years ago

It may be related to Nuxt 3 which is still in beta. I close bug since I didn't get any problem with a simple Vite.js starter project. Thanks for your help.

naomiaro commented 2 years ago

I'm getting this same error when I try importing in next ^12.1.0. I tried both tone and tone@next.

naomiaro commented 2 years ago

I think it has to do with not having extensions (--es-module-specifier-resolution=node). If I manually change the import to "./core/Global.js"; in the library it finds it and then moves on to complain about export * from "./classes";

DronHazra commented 2 years ago

I'm having this issue with next.js as well, see #1077

julianwagle commented 1 year ago

Any fix for this? Why was it closed?

Update: I got it to work by using npm instead of yarn. Not sure why one would work and not the other. I've never seen anything like this before.

mxfng commented 12 months ago

I got Tone v^14.8.49 to work in Next.js v14.0.2 this way (on my component using Tone):

"use client";

import * as Tone from "tone/build/esm/index";
mrclay commented 9 months ago

FYI I'm using Vite 5.0.12 and using SSG in Qwik and I found no solution other than to stick to 14.7

dhawansolanki commented 4 months ago

I got Tone v^14.8.49 to work in Next.js v14.0.2 this way (on my component using Tone):

"use client";

import * as Tone from "tone/build/esm/index";

The same issue is with the same version of tone as well. Do you have any workaround for this?