tldraw icon indicating copy to clipboard operation
tldraw copied to clipboard

[Bug]: Can't resolve 'core-js/stable/array/at'

Open cnichte opened this issue 2 years ago • 1 comments

What happened?

Hi, have installed the npm like so: npm install @tldraw/tldraw@canary

an imported tldraw in the render process of my Electron-App, as in your example...

import { Tldraw } from '@tldraw/tldraw'
import '@tldraw/tldraw/tldraw.css'

But only get this error on start:

ERROR in ./node_modules/@tldraw/editor/dist-esm/index.mjs 255:0-33
Module not found: Error: Can't resolve 'core-js/stable/array/at' in '.../node_modules/@tldraw/editor/dist-esm'

BREAKING CHANGE: The request 'core-js/stable/array/at' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.

Add the extension to the request.
 @ ./node_modules/@tldraw/tldraw/dist-esm/index.mjs 3:0-31 3:0-31

I don't know if this is a bug or if it's me... Any suggestions?

best regards Carsten

How can we reproduce the bug?

No response

What browsers are you seeing the problem on?

Chrome

Contact Details

[email protected]

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

cnichte avatar Sep 26 '23 14:09 cnichte

I had the same error at a regular react app, and npm i core-js --save (yarn add core-js) fixed this issue for me

merobal avatar Dec 11 '23 15:12 merobal

I don't know if this is a bug or if it's me... Any suggestions?

This is a bug in the @tldraw/editor package.

The core-js imports in that package should be changed to include the .js extension. As described at https://nodejs.org/api/esm.html#import-specifiers import statements are required to include the file extension:

There are three types of specifiers: [...]

  • Bare specifiers like 'some-package' or 'some-package/shuffle'. They can refer to the main entry point of a package by the package name, or a specific feature module within a package prefixed by the package name as per the examples respectively. Including the file extension is only necessary for packages without an "exports" field.

This is the type of import specified used, and the core-js package does not have any exports field, so the file extension is therefore required.

trygveaa avatar Feb 23 '24 12:02 trygveaa

Looking now! I'll have a PR that adds the js specifiers.

steveruizok avatar Feb 23 '24 17:02 steveruizok

https://github.com/tldraw/tldraw/pull/2940

steveruizok avatar Feb 23 '24 17:02 steveruizok

Landed, should be resolved now!

steveruizok avatar Feb 23 '24 18:02 steveruizok