Description
Is there an existing issue for this?
- I have searched the existing issues
Current behavior
pnpm run start
aa@0.0.1 start ***
nest start
Error: Cannot find module '@/app.module'
Require stack:
- /dist/main.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1090:15)
at Function.Module._load (node:internal/modules/cjs/loader:934:27)
at Module.require (node:internal/modules/cjs/loader:1157:19)
at require (node:internal/modules/helpers:119:18)
at Object. (/src/main.ts:2:1)
at Module._compile (node:internal/modules/cjs/loader:1275:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
at Module.load (node:internal/modules/cjs/loader:1133:32)
at Function.Module._load (node:internal/modules/cjs/loader:972:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
ELIFECYCLE Command failed with exit code 1.
Minimum reproduction code
https://github.com/zhouweiming/nestjs-demo.git
Steps to reproduce
- clone the minimum reproduction code: https://github.com/zhouweiming/nestjs-demo.git
- cd
- pnpm install
- pnpm start
Expected behavior
- I only made two modifications: 1. Add paths to tsconfig.json; 2. Modify the import of app. module in main.ts
pnpm run start
> aa@0.0.1 start ***
> nest start
Error: Cannot find module '@/app.module'
Require stack:
- ***/dist/main.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1090:15)
at Function.Module._load (node:internal/modules/cjs/loader:934:27)
at Module.require (node:internal/modules/cjs/loader:1157:19)
at require (node:internal/modules/helpers:119:18)
at Object.<anonymous> (***/src/main.ts:2:1)
at Module._compile (node:internal/modules/cjs/loader:1275:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1329:10)
at Module.load (node:internal/modules/cjs/loader:1133:32)
at Function.Module._load (node:internal/modules/cjs/loader:972:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
Package
- I don't know. Or some 3rd-party package
-
@nestjs/common
-
@nestjs/core
-
@nestjs/microservices
-
@nestjs/platform-express
-
@nestjs/platform-fastify
-
@nestjs/platform-socket.io
-
@nestjs/platform-ws
-
@nestjs/testing
-
@nestjs/websockets
- Other (see below)
Other package
No response
NestJS version
9.0.0
Packages versions
{
"name": "aa",
"version": "0.0.1",
"description": "",
"author": "",
"private": true,
"license": "UNLICENSED",
"scripts": {
"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": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
"@nestjs/common": "^9.0.0",
"@nestjs/core": "^9.0.0",
"@nestjs/platform-express": "^9.0.0",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.2.0"
},
"devDependencies": {
"@nestjs/cli": "^9.0.0",
"@nestjs/schematics": "^9.0.0",
"@nestjs/testing": "^9.0.0",
"@types/express": "^4.17.13",
"@types/jest": "29.5.1",
"@types/node": "18.16.12",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^5.0.0",
"@typescript-eslint/parser": "^5.0.0",
"eslint": "^8.0.1",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"jest": "29.5.0",
"prettier": "^2.3.2",
"source-map-support": "^0.5.20",
"supertest": "^6.1.3",
"ts-jest": "29.1.0",
"ts-loader": "^9.2.3",
"ts-node": "^10.0.0",
"tsconfig-paths": "4.2.0",
"typescript": "^5.0.0"
},
"jest": {
"moduleFileExtensions": [
"js",
"json",
"ts"
],
"rootDir": "src",
"testRegex": ".*\\.spec\\.ts$",
"transform": {
"^.+\\.(t|j)s$": "ts-jest"
},
"collectCoverageFrom": [
"**/*.(t|j)s"
],
"coverageDirectory": "../coverage",
"testEnvironment": "node",
"moduleNameMapper": {
"^@/(.*)$": "<rootDir>/../src/$1"
}
}
}
Node.js version
v19.7.0
In which operating systems have you tested?
- macOS
- Windows
- Linux
Other
nest info
| \ | | | | |_ |/ |/ __ | | | |
| | | ___ ___ | | | |\ --. | / \/| | | | | .
| / _ / __|| __| | | `--. | | | | | |
| |\ || /_ | | /_/ //_/ /| _/| |_____| |
_| _/ _||/ _|_/ _/ _/__/___/
[System Information]
OS Version : macOS Unknown
NodeJS Version : v19.7.0
PNPM Version : 8.6.0
[Nest CLI]
Nest CLI Version : 9.0.0
[Nest Platform Information]
platform-express version : 9.0.0
schematics version : 9.0.0
testing version : 9.0.0
common version : 9.0.0
core version : 9.0.0
cli version : 9.0.0