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

ERR_LOADER_CHAIN_INCOMPLETE with node v16.17 #1865

Closed
samuelint opened this issue Aug 17, 2022 · 3 comments
Closed

ERR_LOADER_CHAIN_INCOMPLETE with node v16.17 #1865

samuelint opened this issue Aug 17, 2022 · 3 comments

Comments

@samuelint
Copy link

Search Terms

  • ERR_LOADER_CHAIN_INCOMPLETE
  • "ts-node/esm 'resolve'" did not call the next hook in its chain and did not explicitly signal a short circuit

Expected Behavior

no error when executing mocha 'src/**/*.spec.ts'

Actual Behavior

When executing
mocha 'src/**/*.spec.ts'

the following error happen on node v16.17 but not on node v16.16

Error [ERR_LOADER_CHAIN_INCOMPLETE]: "ts-node/esm 'resolve'" did not call the next hook in its chain and did not explicitly signal a short circuit. If this is intentional, include `shortCircuit: true` in the hook's return.
    at new NodeError (node:internal/errors:[38]7:5)
    at ESMLoader.resolve (node:internal/modules/esm/loader:852:13)
    at async ESMLoader.getModuleJob (node:internal/modules/esm/loader:431:7)
    at async Promise.all (index 0)
    at async ESMLoader.import (node:internal/modules/esm/loader:533:24)
    at async loadESM (node:internal/process/esm_loader:91:5)
    at async handleMainPromise (node:internal/modules/run_main:65:12) {
  code: 'ERR_LOADER_CHAIN_INCOMPLETE'
}
error Command failed with exit code 1.

Steps to reproduce the problem

Use node v16.17 or node16:latest
Use

  • mocha ^9.2.2
  • typescript ^4.6.3
  • ts-node ^10.7.0

Minimal reproduction

  • Have any mocha + ts-node + node 16.17 project

Specifications

  • ts-node version: ^10.7.0
  • node version: 16.17
  • TypeScript version:^4.6.3
  • mocha ^9.2.2
/* Visit https://aka.ms/tsconfig.json to read more about this file */
{
  "compilerOptions": {
    "target": "es2020",
    "module": "esnext",
    "moduleResolution": "node",
    "lib": [
      "es2019",
      "es2020.promise",
      "es2020.bigint",
      "es2020.string",
      "esnext.asynciterable"
    ],
    "declaration": true,
    "declarationMap": true,
    "sourceMap": true,
    "outDir": "./dist",
    "rootDir": "./src",

    "removeComments": true,

    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "strictFunctionTypes": true,
    "strictBindCallApply": true,
    "strictPropertyInitialization": true,
    "noImplicitThis": true,
    "alwaysStrict": true,

    "noUnusedLocals": true,
    "noUnusedParameters": false,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": true,
    "noUncheckedIndexedAccess": true,
    "skipLibCheck": true,
    "forceConsistentCasingInFileNames": true,

    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,

    "experimentalDecorators": true,
    "emitDecoratorMetadata": true
  },
  "ts-node": {
    "esm": true
  },
  "include": ["src/**/*.ts"],
  "exclude": ["node_modules", "**/node_modules/*", "**/*.spec.ts"]
}
  • package.json:
{
  "version": "1.0.0",
  "private": true,
  "type": "module",
  "engines": {
    "node": ">=16.14.0"
  },
  "scripts": {
    "start": "nodemon --watch src -e ts,tsx --ignore '*.spec.ts*' --exec 'yarn server'",
    "server": "node --loader ts-node/esm --es-module-specifier-resolution=node --no-warnings ./src/index.ts",
    "server:prod": "yarn build && node --es-module-specifier-resolution=node ./dist/index.js",
    "clean": "rimraf dist/",
    "copy-static-files": "copyfiles --all -u 1 \"src/**/*.gql\" \"dist\"",
    "build": "yarn clean && tsc --outdir ./dist && yarn copy-static-files",
    "format": "prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\"",
    "lint": "eslint --ext .ts .",
    "lint:fix": "eslint --fix --ext .ts .",
    "test:unit": "TS_NODE_PROJECT='./tsconfig.test.json' mocha",
    "test:unit:all": "yarn test:unit 'src/**/*.spec.ts'",
    "test:unit:watch": "yarn test:unit:all --parallel --watch",
    "test:integration": "TS_NODE_PROJECT='./tsconfig.test.json' mocha -r test/integration/setup.ts",
    "test:integration:all": "yarn test:integration 'test/integration/**/*.spec.ts'",
    "test:integration:all:wait-on": "wait-on http://localhost:8080 && yarn test:integration:all"
  },
  "dependencies": {
    "@apollo/client": "^3.6.9",
    "@drewkimberly/permutations": "1.x",
    "@godaddy/terminus": "^4.10.2",
    "@types/express": "^4.17.13",
    "@types/lodash": "^4.14.182",
    "@types/mocha": "^9.1.0",
    "@types/morgan": "^1.9.3",
    "@types/node": "^17.0.25",
    "apollo-server-core": "^3.6.7",
    "apollo-server-express": "^3.6.7",
    "axios": "^0.26.1",
    "colors": "^1.4.0",
    "cross-fetch": "^3.1.5",
    "dotenv": "^16.0.0",
    "express": "^4.17.3",
    "graphql": "^16.4.0",
    "inversify": "^6.0.1",
    "inversify-express-utils": "^6.4.3",
    "lodash": "^4.17.21",
    "mocha": "^9.2.2",
    "morgan": "^1.10.0",
    "reflect-metadata": "^0.1.13",
    "walk-sync": "^3.0.0",
    "winston": "^3.7.2"
  },
  "devDependencies": {
    "@types/chai-as-promised": "^7.1.5",
    "@types/sinon": "^10.0.11",
    "@typescript-eslint/eslint-plugin": "^5.20.0",
    "@typescript-eslint/parser": "^5.20.0",
    "chai": "^4.3.6",
    "chai-as-promised": "^7.1.1",
    "chai-graphql": "^4.0.0",
    "chai-http": "^4.3.0",
    "copyfiles": "^2.4.1",
    "eslint": "^8.13.0",
    "eslint-config-prettier": "^8.5.0",
    "eslint-config-standard": "^17.0.0",
    "eslint-plugin-import": "^2.26.0",
    "eslint-plugin-n": "^15.1.0",
    "eslint-plugin-promise": "^6.0.0",
    "mocha-better-spec-reporter": "^3.1.0",
    "mockttp": "^2.7.0",
    "nodemon": "^2.0.15",
    "prettier": "2.6.2",
    "rimraf": "^3.0.2",
    "sinon": "^13.0.2",
    "ts-node": "^10.7.0",
    "typescript": "^4.6.3",
    "wait-on": "^6.0.1"
  }
}

  • Operating system and version:
  • Tested inside docker node:16-alpine & node:16.17-alpine
@cspotcode
Copy link
Collaborator

Dupe of #1839.

@samuelint
Copy link
Author

Not exactly a dupe.
#1839.
Says it happen with node v18.6.0. Here the problem happen with node v16. Even if the ERR_LOADER_CHAIN_INCOMPLETE error has been added to node in node 18.6.0 (https://nodejs.org/api/errors.html#err_loader_chain_incomplete)

@cspotcode
Copy link
Collaborator

#1839 (comment)

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

No branches or pull requests

2 participants