1

I have a Node/Express application with TypeScript but somehow I get an alias error when I try to run the app in Digital Ocean droplet, although everything works fine in my local environment:

/VHF/.npm/_npx/112a5e3dd6e78d88/node_modules/tsc-alias/dist/index.js:60
        yield (0, helpers_1.importReplacers)(config, replacers, options.replacers);
                                            ^

TypeError: (0 , helpers_1.importReplacers) is not a function
    at /VHF/.npm/_npx/112a5e3dd6e78d88/node_modules/tsc-alias/dist/index.js:60:45
    at Generator.next (<anonymous>)
    at /VHF/.npm/_npx/112a5e3dd6e78d88/node_modules/tsc-alias/dist/index.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/VHF/.npm/_npx/112a5e3dd6e78d88/node_modules/tsc-alias/dist/index.js:4:12)
    at replaceTscAliasPaths (/VHF/.npm/_npx/112a5e3dd6e78d88/node_modules/tsc-alias/dist/index.js:28:12)
    at Object.<anonymous> (/VHF/.npm/_npx/112a5e3dd6e78d88/node_modules/tsc-alias/dist/bin/index.js:17:30)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)

This is package.json:

{
  "name": "vhf-digital-lending-api",
  "version": "1.0.0",
  "description": "API for VHF digital lender and payment platform",
  "author": "",
  "license": "ISC",
  "scripts": {
    "start": "npm run build&& cross-env; NODE_ENV=production node dist/server.js",
    "dev": "cross-env NODE_ENV=development nodemon",
    "build": "tsc && npx tsc-alias",
    "test": "jest --forceExit --detectOpenHandles",
    "lint": "eslint --ignore-path .gitignore --ext .ts src/",
    "lint:fix": "npm run lint -- --fix",
    "migrate:generate": "ts-node ./node_modules/typeorm/cli.js migration:generate --config src/databases/index.ts -n",
    "migration:run": "ts-node --transpile-only ./node_modules/typeorm/cli.js migration:run --config src/databases/index.ts",
    "migration:revert": "ts-node --transpile-only ./node_modules/typeorm/cli.js migration:revert --config src/databases/index.ts"
  },
  "dependencies": {
    "@types/cookie-session": "^2.0.44",
    "@types/express-session": "^1.17.0",
    "agenda": "^4.2.1",
    "bcrypt": "^5.0.1",
    "class-transformer": "^0.4.0",
    "class-validator": "^0.13.1",
    "compression": "^1.7.4",
    "config": "^3.3.6",
    "cookie-parser": "^1.4.5",
    "cookie-session": "^2.0.0",
    "cors": "^2.8.5",
    "cross-env": "^7.0.3",
    "date-fns": "^2.24.0",
    "dotenv": "^9.0.0",
    "envalid": "^7.1.0",
    "express": "^4.17.1",
    "helmet": "^4.6.0",
    "hpp": "^0.2.3",
    "jest": "^26.6.3",
    "joi": "^17.4.2",
    "jsonwebtoken": "^8.5.1",
    "mkdirp": "^1.0.4",
    "morgan": "^1.10.0",
    "multer": "^1.4.3",
    "node-fetch": "^2.6.6",
    "pg": "^8.7.1",
    "reflect-metadata": "^0.1.13",
    "swagger-jsdoc": "^6.1.0",
    "swagger-ui-express": "^4.1.6",
    "ts-jest": "^26.5.6",
    "ts-node": "^9.1.1",
    "typeorm": "^0.2.38",
    "typeorm-pagination": "^2.0.3",
    "typescript": "^4.4.4",
    "winston": "^3.3.3",
    "winston-daily-rotate-file": "^4.5.4",
    "xml2js": "^0.4.23"
  },
  "devDependencies": {
    "@types/bcrypt": "^3.0.1",
    "@types/compression": "^1.7.2",
    "@types/config": "0.0.38",
    "@types/cookie-parser": "^1.4.2",
    "@types/cors": "^2.8.12",
    "@types/dotenv": "^8.2.0",
    "@types/express": "^4.17.13",
    "@types/helmet": "^4.0.0",
    "@types/hpp": "^0.2.2",
    "@types/jest": "^26.0.24",
    "@types/jsonwebtoken": "^8.5.5",
    "@types/mongoose": "^5.11.97",
    "@types/morgan": "^1.9.3",
    "@types/node": "^15.14.9",
    "@types/supertest": "^2.0.11",
    "@types/swagger-jsdoc": "^6.0.1",
    "@types/swagger-ui-express": "^4.1.3",
    "@types/winston": "^2.4.4",
    "@types/xml2js": "^0.4.9",
    "@typescript-eslint/eslint-plugin": "^4.22.1",
    "@typescript-eslint/parser": "^4.22.1",
    "eslint": "^7.25.0",
    "eslint-config-prettier": "^8.3.0",
    "eslint-plugin-prettier": "^3.4.1",
    "husky": "^6.0.0",
    "lint-staged": "^10.5.4",
    "node-config": "0.0.2",
    "node-gyp": "^8.3.0",
    "nodemon": "^2.0.14",
    "prettier": "^2.4.1",
    "supertest": "^6.1.6",
    "tsconfig-paths": "^3.11.0"
  }
}

and this is my tsconfig.json:

{
  "compileOnSave": false,
  "compilerOptions": {
    "target": "es2017",
    "lib": ["es2017", "esnext.asynciterable"],
    "typeRoots": ["node_modules/@types"],
    "allowSyntheticDefaultImports": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "forceConsistentCasingInFileNames": true,
    "moduleResolution": "node",
    "module": "commonjs",
    "pretty": true,
    "sourceMap": true,
    "declaration": true,
    "outDir": "./dist",
    "allowJs": true,
    "noEmit": false,
    "esModuleInterop": true,
    "resolveJsonModule": true,
    "importHelpers": true,
    "baseUrl": "src",
    "paths": {
      // "@/*": ["*"],
      // "@controllers/*": ["controllers/*"],
      // "@databases": ["databases"],
      // "@dtos/*": ["dtos/*"],
      // "@entity/*": ["entity/*"],
      // "@exceptions/*": ["exceptions/*"],
      // "@interfaces/*": ["interfaces/*"],
      // "@middlewares/*": ["middlewares/*"],
      // "@routes/*": ["routes/*"],
      // "@services/*": ["services/*"],
      // "@utils/*": ["utils/*"]
    }
  },
  "include": ["src/**/*.ts", "src/**/*.json", ".env"],
  "exclude": ["node_modules"]
}

I tried commenting out the aliases but it doesn't seem to work.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.