Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Super Quick Example fails to run on Node v14 #1168

Closed
EulerTourist opened this issue May 1, 2020 · 4 comments
Closed

Super Quick Example fails to run on Node v14 #1168

EulerTourist opened this issue May 1, 2020 · 4 comments

Comments

@EulerTourist
Copy link

EulerTourist commented May 1, 2020

Description
Super quick example fails to run

Expected Result

Actual Result
import { createMachine, interpret } from 'xstate';
^^^^^^^^^
SyntaxError: The requested module 'xstate' does not provide an export named 'interpret'
at ModuleJob._instantiate (internal/modules/esm/module_job.js:92:21)
at async ModuleJob.run (internal/modules/esm/module_job.js:107:20)
at async Loader.import (internal/modules/esm/loader.js:179:24)
steve@Steves-MBP src % node -v
v14.0.0

@davidkpiano
Copy link
Member

cc. @Andarist Is this an ESM issue?

@EulerTourist
Copy link
Author

I am able to get it going for now with:

import fsm from 'xstate';
const lightMachine = fsm.createMachine(config);

//also as service
const lightService = fsm.interpret(lightMachine);

@Andarist
Copy link
Member

Andarist commented May 1, 2020

Duplicate of #963

@Andarist Is this an ESM issue?

Yes. We currently don't provide enough information for node (through package.json) for it to be able to load our ESM files. The issue is not so simple as it might look like though, comes with some caveats and at this point in time changing it for v4 would be a breaking change for every ESM consumer in node as they would have to change all import statements for XState. The support for modules in node is also still considered as experimental so I don't really think that we should jump into fixing this straight away (especially that - as mentioned - this only looks trivial, we also don't know yet how bundlers will handle conditional exports which are expected to be handled by them)

@davidkpiano
Copy link
Member

Closing as duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants