Skip to content

Provide more information when there is a SyntaxError #56830

@Ethan-Arrowood

Description

@Ethan-Arrowood

I'm working on migrating a large JS/TS repo to using Node.js v23 type-stripping. I've already applied some codemods to transform requires & imports, as well as remove TS specific syntax. I'm now running into some syntax errors regarding missing exports which I think were silently being ignored previously. The error does not say what file it is coming from and that is proving difficult to track down. Can amaro print that info? Thank you!

For example:

> node bin/harperdb.js                                                                                                                                                          
(node:25707) ExperimentalWarning: Type Stripping is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:25707) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file:///Users/ethan/dev/harperdb/harperdb/resources/databases.ts is not specified and it doesn't parse as CommonJS.
Reparsing as ES module because module syntax was detected. This incurs a performance overhead.
To eliminate this warning, add "type": "module" to /Users/ethan/dev/harperdb/harperdb/package.json.
SyntaxError: The requested module 'lmdb' does not provide an export named 'Transaction'
    at ModuleJobSync.runSync (node:internal/modules/esm/module_job:385:37)
    at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:363:47)
    at loadESMFromCJS (node:internal/modules/cjs/loader:1569:24)
    at Module._compile (node:internal/modules/cjs/loader:1721:5)
    at Object.loadTS [as .ts] (node:internal/modules/cjs/loader:1831:10)
    at Module.load (node:internal/modules/cjs/loader:1473:32)
    at Function._load (node:internal/modules/cjs/loader:1285:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:234:24)
    at Module.require (node:internal/modules/cjs/loader:1495:12)
2025-01-14T17:11:39.050Z [main/0] [error]: SyntaxError: The requested module 'lmdb' does not provide an export named 'Transaction'
    at ModuleJobSync.runSync (node:internal/modules/esm/module_job:385:37)
    at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:363:47)
    at loadESMFromCJS (node:internal/modules/cjs/loader:1569:24)
    at Module._compile (node:internal/modules/cjs/loader:1721:5)
    at Object.loadTS [as .ts] (node:internal/modules/cjs/loader:1831:10)
    at Module.load (node:internal/modules/cjs/loader:1473:32)
    at Function._load (node:internal/modules/cjs/loader:1285:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:234:24)
    at Module.require (node:internal/modules/cjs/loader:1495:12)

Metadata

Metadata

Assignees

No one assigned

    Labels

    strip-typesIssues or PRs related to strip-types support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions