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

"TypeError: require(...) is not a function" in ts-node dependecy #2089

Open
adrielgama opened this issue Nov 22, 2023 · 0 comments
Open

"TypeError: require(...) is not a function" in ts-node dependecy #2089

adrielgama opened this issue Nov 22, 2023 · 0 comments

Comments

@adrielgama
Copy link

Search Terms

ts-node finalhandler require

Expected Behavior

Running project without problems

Actual Behavior

Failed to start

Steps to reproduce the problem

Run yarn start:dev: nodemon --watch 'src/**' --exec npx ts-node -r tsconfig-paths/register dev-infra.ts -e ts

Minimal reproduction

[nodemon] 2.0.22
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): 'src\**'
[nodemon] watching extensions: ts
[nodemon] starting `npx ts-node -r tsconfig-paths/register dev-infra.ts`
[server] running
C:\Users\proce\Documents\F\T\node_modules\finalhandler\index.js:14
var debug = require('debug')('finalhandler')
                            ^
TypeError: require(...) is not a function
    at Object.<anonymous> (C:\Users\proce\Documents\F\T\node_modules\finalhandler\index.js:14:29)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
    at Object.require.extensions.<computed> [as .js] (C:\Users\proce\Documents\F\T\node_modules\ts-node\src\index.ts:1608:43)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Function.Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:119:18)
    at Object.<anonymous> (C:\Users\proce\Documents\F\T\node_modules\express\lib\application.js:16:20)
    at Module._compile (node:internal/modules/cjs/loader:1256:14)
[nodemon] app crashed - waiting for file changes before starting...

Specifications

  • ts-node version: 10.9.1
  • node version: 18.18.0
  • TypeScript version: 4.9.5
  • tsconfig.json, if you're using one:
{
  "compilerOptions": {
    "target": "ES2021",
    "module": "CommonJS",
    "types": ["node", "jest", "reflect-metadata", "multer"],
    "allowJs": true,
    "importHelpers": true,
    "baseUrl": ".",
    "rootDir": ".",
    "outDir": "dist",
    "removeComments": true,
    "skipLibCheck": true,
    "resolveJsonModule": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "esModuleInterop": true,
    "sourceMap": true,
    "noUncheckedIndexedAccess": true,
    "strictNullChecks": true,
    "paths": {
      "@domain/*": ["./src/domain/*"],
      "@infra/*": ["./src/infra/*"],
      "@main/*": ["./src/main/*"],
      "@tests/*": ["./tests/*"]
    }
  },
  "include": ["debug.ts", "src/**/*", "tests/**/*", "dev-infra.ts"]
}
  • package.json:
{
  "name": "t",
  "version": "1.0.0",
  "description": "",
  "private": true,
  "main": "index.js",
  "scripts": {
    "infra": "node dev-infra.js",
    "build": "swc src -d build",
    "test": "jest --runInBand --passWithNoTests --detectOpenHandles --silent --bail",
    "test:cov": "jest --runInBand --silent --coverage",
    "start": "node ./build/main/server.js",
    "start:dev": "nodemon --watch 'src/**' --exec npx ts-node -r tsconfig-paths/register dev-infra.ts -e ts",
    "typeorm": "node -r ts-node/register ./node_modules/typeorm/cli -d ./data-source.ts",
    "prepare": "husky install",
    "debug": "ts-node -r tsconfig-paths/register ./debug.ts"
  },
  "devDependencies": {
    "@commitlint/cli": "^17.4.3",
    "@commitlint/config-conventional": "^17.4.3",
    "@faker-js/faker": "^8.0.2",
    "@swc/cli": "^0.1.57",
    "@swc/core": "^1.2.196",
    "@types/aws-lambda": "^8.10.110",
    "@types/express": "^4.17.17",
    "@types/jest": "^29.0.3",
    "@types/luxon": "^3.3.2",
    "@types/multer": "^1.4.9",
    "@types/node": "^18.17.1",
    "@types/supertest": "^2.0.12",
    "@types/swagger-ui-express": "^4.1.3",
    "@typescript-eslint/eslint-plugin": "^5.52.0",
    "@typescript-eslint/parser": "^5.52.0",
    "eslint": "^8.34.0",
    "eslint-config-airbnb-base": "^15.0.0",
    "eslint-config-standard": "^17.0.0",
    "eslint-import-resolver-typescript": "^3.5.3",
    "eslint-plugin-import": "^2.27.5",
    "eslint-plugin-jest": "^24.1.5",
    "eslint-plugin-n": "^15.6.1",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-promise": "^6.1.1",
    "eslint-plugin-security": "^1.4.0",
    "eslint-plugin-you-dont-need-lodash-underscore": "^6.11.0",
    "git-commit-msg-linter": "^4.1.3",
    "husky": "^8.0.3",
    "jest": "^29.0.3",
    "lint-staged": "^13.2.3",
    "nodemon": "^2.0.20",
    "serverless": "^3.19.0",
    "serverless-dotenv-plugin": "^4.0.1",
    "serverless-offline": "^12.0.4",
    "serverless-plugin-typescript": "^2.1.4",
    "supertest": "^6.3.3",
    "swagger-ui-express": "^5.0.0",
    "testcontainers": "^9.10.0",
    "ts-jest": "^29.0.1",
    "ts-node": "^10.9.1",
    "tsc-alias": "^1.7.0",
    "tsconfig-paths": "^4.2.0",
    "typescript": "^4.9.5"
  },
  "dependencies": {
    "@aws-sdk/client-kinesis": "^3.363.0",
    "@aws-sdk/client-secrets-manager": "^3.338.0",
    "aws-sdk": "^2.1315.0",
    "axios": "^1.4.0",
    "dotenv": "^16.1.3",
    "express": "^4.18.2",
    "install": "^0.13.0",
    "inversify": "^6.0.1",
    "inversify-express-utils": "^6.4.3",
    "luxon": "^3.4.3",
    "mongodb": "^5.7.0",
    "multer": "^1.4.5-lts.1",
    "mysql2": "^3.6.1",
    "node-cache": "^5.1.2",
    "npm": "^9.8.1",
    "pino": "^8.11.0",
    "pino-pretty": "^9.3.0",
    "reflect-metadata": "^0.1.13",
    "swagger-express-ts": "^1.1.0",
    "swc": "^1.0.11",
    "typeorm": "^0.3.17",
    "yup": "^1.0.0"
  },
  "engines": {
    "npm": "please-use-yarn"
  },
  "lint-staged": {
    "*.ts": [
      "prettier -w",
      "eslint --cache --fix --ext .ts"
    ]
  }
}

  • Operating system and version: Windows 11 - 22H2 (22621.2715)
  • If Windows, are you using WSL or WSL2?:
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

1 participant