Skip to content

Extensionsless "bin" scripts has conflict with Node --experimental-specifier-resolution option #39381

@sosoba

Description

@sosoba

TypeScript Version: 3.9.6

Search Terms:
experimental-specifier-resolution
extensinless
Code

package.json

{
  "name": "test",
  "devDependencies": {
    "typescript": "^3.9.6"
  },
  "scripts": {
    "test": "tsc -v"
  }
}

.npmrc

node-options="--experimental-specifier-resolution=node"
npm i
npm test

Expected behavior:

$ npm test
Version 3.9.6

Actual behavior:

$ npm test
(node:17248) ExperimentalWarning: The ESM module loader is experimental.
internal/modules/run_main.js:54
    internalBinding('errors').triggerUncaughtException(
                              ^

TypeError [ERR_INVALID_RETURN_PROPERTY_VALUE]: Expected string to be returned for the "format" from the "loader getFormat" function but got type object.
    at Loader.getFormat (internal/modules/esm/loader.js:122:13)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Loader.getModuleJob (internal/modules/esm/loader.js:244:20)
    at async Loader.import (internal/modules/esm/loader.js:178:17) {
  code: 'ERR_INVALID_RETURN_PROPERTY_VALUE'
}
npm ERR! Test failed.  See above for more details.

Related Issues:
nodejs/modules#488
nodejs/node#31415

This behaviour is the result of "extensionless" bin scripts:

    "bin": {
        "tsc": "./bin/tsc",
        "tsserver": "./bin/tsserver"
    },

Metadata

Metadata

Assignees

No one assigned

    Labels

    ExternalRelates to another program, environment, or user action which we cannot control.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions