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

"Fix" for ts-node-issue-1671 #24

Open
wants to merge 4 commits into
base: ts-node-issue-1671
Choose a base branch
from

Conversation

tkrotoff
Copy link

@tkrotoff tkrotoff commented Mar 10, 2022

back directory is independent: it has its own package.json

  • fails with ts-node, commit: 43ab899
(node:33894) ExperimentalWarning: --experimental-loader is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
file:///dev/ts-node-repros/back/server.ts:1
import { getErrorMessage } from './common/getErrorMessage';
         ^^^^^^^^^^^^^^^
SyntaxError: Named export 'getErrorMessage' not found. The requested module './common/getErrorMessage' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from './common/getErrorMessage';
const { getErrorMessage } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:127:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:191:5)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:337:24)
    at async loadESM (node:internal/process/esm_loader:88:5)
    at async handleMainPromise (node:internal/modules/run_main:61:12)
Process exited with code: 1
  • fails with Node.js without ts-node: a12a271

    Try without ts-node: it fails also with Node.js 😱

  • works with Node.js with root package.json with type: module: ea5cf93

    Node.js requires a root package.json with type: module 😑

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

Successfully merging this pull request may close these issues.

1 participant