nestjs / nest-cli

CLI tool for Nest applications 🍹
https://nestjs.com
Other
1.95k stars 389 forks source link

Facing module unavailability error on changing the bundler to swc #2433

Closed RyanWalker277 closed 8 months ago

RyanWalker277 commented 8 months ago

Is there an existing issue for this?

Current behavior

image

We are facing this error on migrating our nest app to swc. On checking the imports, the imported file is there. Can anyone help us debug what's wrong here?

Minimum reproduction code

https://github.com/RyanWalker277/stencil-package/tree/change_bundler

Steps to reproduce

No response

Expected behavior

It should compile wthout this dependency error.

Package

Other package

No response

NestJS version

10.0.5

Packages versions

{
  "name": "nestjs-boilerplate",
  "version": "0.0.1",
  "description": "",
  "author": "",
  "private": true,
  "license": "MIT",
  "scripts": {
    "seed:create": "hygen seeds create",
    "seed:run": "ts-node -r tsconfig-paths/register ./src/database/seeds/run-seed.ts",
    "prebuild": "rimraf dist",
    "build": "nest build",
    "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
    "start": "nest start",
    "start:dev": "nest start --watch",
    "start:debug": "nest start --debug --watch",
    "start:prod": "node dist/main",
    "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
    "test": "jest",
    "test:watch": "jest --watch",
    "test:cov": "jest --coverage",
    "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
    "test:e2e": "env-cmd jest --config ./test/jest-e2e.json",
    "prepare": "is-ci || husky install"
  },
  "dependencies": {
    "@aws-sdk/client-s3": "3.360.0",
    "@nestjs/cache-manager": "^2.1.1",
    "@nestjs/common": "10.0.5",
    "@nestjs/config": "3.0.0",
    "@nestjs/core": "10.0.5",
    "@nestjs/jwt": "10.1.0",
    "@nestjs/passport": "10.0.0",
    "@nestjs/platform-express": "10.0.5",
    "@nestjs/swagger": "7.1.1",
    "@nestjs/terminus": "^10.2.0",
    "@nestjs/typeorm": "^10.0.1",
    "@prisma/client": "^5.3.1",
    "@techsavvyash/user-service": "^0.0.2",
    "@types/multer-s3": "^3.0.0",
    "apple-signin-auth": "1.7.5",
    "axios": "^1.6.2",
    "bcryptjs": "2.4.3",
    "cache-manager-redis-store": "^3.0.1",
    "class-transformer": "0.5.1",
    "class-validator": "0.14.0",
    "fb": "2.0.0",
    "google-auth-library": "8.9.0",
    "handlebars": "4.7.7",
    "ioredis": "^5.3.2",
    "ms": "^2.1.3",
    "multer": "1.4.4",
    "multer-s3": "3.0.1",
    "nestjs-i18n": "10.2.6",
    "nodemailer": "6.9.3",
    "passport": "0.6.0",
    "passport-anonymous": "1.0.1",
    "passport-jwt": "4.0.1",
    "pg": "^8.11.3",
    "prom-client": "^15.0.0",
    "redis": "^4.6.12",
    "redis-healthcheck": "^0.1.1",
    "reflect-metadata": "0.1.13",
    "rimraf": "5.0.1",
    "rxjs": "7.8.1",
    "source-map-support": "0.5.21",
    "swagger-ui-express": "4.6.3",
    "twitter": "1.7.1",
    "typeorm": "^0.3.17"
  },
  "devDependencies": {
    "@nestjs/cli": "10.1.7",
    "@nestjs/schematics": "10.0.1",
    "@nestjs/testing": "10.0.5",
    "@swc/cli": "^0.1.63",
    "@swc/core": "^1.3.101",
    "@types/bcryptjs": "2.4.2",
    "@types/express": "4.17.17",
    "@types/facebook-js-sdk": "3.3.6",
    "@types/jest": "29.5.2",
    "@types/ms": "^0.7.31",
    "@types/multer": "1.4.7",
    "@types/node": "18.16.19",
    "@types/passport-anonymous": "1.0.3",
    "@types/passport-jwt": "3.0.8",
    "@types/supertest": "2.0.12",
    "@types/twitter": "1.7.1",
    "@typescript-eslint/eslint-plugin": "5.61.0",
    "@typescript-eslint/parser": "5.61.0",
    "env-cmd": "10.1.0",
    "eslint": "8.44.0",
    "eslint-config-prettier": "8.8.0",
    "eslint-plugin-import": "2.27.5",
    "eslint-plugin-prettier": "4.2.1",
    "husky": "8.0.3",
    "hygen": "6.2.11",
    "is-ci": "3.0.1",
    "jest": "29.6.0",
    "prettier": "2.8.8",
    "prisma": "^5.3.1",
    "supertest": "6.3.3",
    "ts-jest": "29.1.1",
    "ts-loader": "9.4.4",
    "ts-node": "10.9.1",
    "tsconfig-paths": "4.2.0",
    "tslib": "2.6.0",
    "typescript": "5.1.6"
  },
  "jest": {
    "moduleFileExtensions": [
      "js",
      "json",
      "ts"
    ],
    "rootDir": "src",
    "testRegex": ".*\\.spec\\.ts$",
    "transform": {
      "^.+\\.(t|j)s$": "ts-jest"
    },
    "collectCoverageFrom": [
      "**/*.(t|j)s"
    ],
    "coverageDirectory": "../coverage",
    "testEnvironment": "node"
  },
  "engines": {
    "node": ">=16.0.0"
  }
}

Node.js version

v16.18.0

In which operating systems have you tested?

Other

No response

kamilmysliwiec commented 8 months ago

Regardless of whether you use swc or tsc, you should never use absolute paths that include src directory. This usually indicates that your ts configuration is invalid.

From the looks of it, this could be better discussed on our Discord. If you haven't already, please join here and send a new post in the #⁠ 🐈 nestjs-help forum. Make sure to include a link to this issue, so you don't need to write it all again. We have a large community of helpful members, who will assist you in getting this to work.