cli build failure after update nest-cli to 8.2.2
Is there an existing issue for this?
- [X] I have searched the existing issues
Current behavior
When run nest build with cli version 8.2.2, it throws following error:
Error: Cannot find module 'ajv/dist/compile/codegen'
Require stack:
- C:\Repositories\typescript-starter\node_modules\ajv-keywords\dist\definitions\typeof.js
- C:\Repositories\typescript-starter\node_modules\ajv-keywords\dist\keywords\typeof.js
- C:\Repositories\typescript-starter\node_modules\ajv-keywords\dist\keywords\index.js
- C:\Repositories\typescript-starter\node_modules\ajv-keywords\dist\index.js
- C:\Repositories\typescript-starter\node_modules\schema-utils\dist\validate.js
- C:\Repositories\typescript-starter\node_modules\schema-utils\dist\index.js
- C:\Repositories\typescript-starter\node_modules\fork-ts-checker-webpack-plugin\lib\plugin.js
- C:\Repositories\typescript-starter\node_modules\fork-ts-checker-webpack-plugin\lib\index.js
- C:\Repositories\typescript-starter\node_modules\@nestjs\cli\lib\compiler\defaults\webpack-defaults.js
- C:\Repositories\typescript-starter\node_modules\@nestjs\cli\lib\compiler\webpack-compiler.js
- C:\Repositories\typescript-starter\node_modules\@nestjs\cli\actions\build.action.js
- C:\Repositories\typescript-starter\node_modules\@nestjs\cli\actions\index.js
- C:\Repositories\typescript-starter\node_modules\@nestjs\cli\commands\command.loader.js
- C:\Repositories\typescript-starter\node_modules\@nestjs\cli\commands\index.js
- C:\Repositories\typescript-starter\node_modules\@nestjs\cli\bin\nest.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:101:18)
at Object.<anonymous> (C:\Repositories\typescript-starter\node_modules\ajv-keywords\dist\definitions\typeof.js:3:19)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Repositories\\typescript-starter\\node_modules\\ajv-keywords\\dist\\definitions\\typeof.js',
'C:\\Repositories\\typescript-starter\\node_modules\\ajv-keywords\\dist\\keywords\\typeof.js',
'C:\\Repositories\\typescript-starter\\node_modules\\ajv-keywords\\dist\\keywords\\index.js',
'C:\\Repositories\\typescript-starter\\node_modules\\ajv-keywords\\dist\\index.js',
'C:\\Repositories\\typescript-starter\\node_modules\\schema-utils\\dist\\validate.js',
'C:\\Repositories\\typescript-starter\\node_modules\\schema-utils\\dist\\index.js',
'C:\\Repositories\\typescript-starter\\node_modules\\fork-ts-checker-webpack-plugin\\lib\\plugin.js',
'C:\\Repositories\\typescript-starter\\node_modules\\fork-ts-checker-webpack-plugin\\lib\\index.js',
'C:\\Repositories\\typescript-starter\\node_modules\\@nestjs\\cli\\lib\\compiler\\defaults\\webpack-defaults.js',
'C:\\Repositories\\typescript-starter\\node_modules\\@nestjs\\cli\\lib\\compiler\\webpack-compiler.js',
'C:\\Repositories\\typescript-starter\\node_modules\\@nestjs\\cli\\actions\\build.action.js',
'C:\\Repositories\\typescript-starter\\node_modules\\@nestjs\\cli\\actions\\index.js',
'C:\\Repositories\\typescript-starter\\node_modules\\@nestjs\\cli\\commands\\command.loader.js',
'C:\\Repositories\\typescript-starter\\node_modules\\@nestjs\\cli\\commands\\index.js',
'C:\\Repositories\\typescript-starter\\node_modules\\@nestjs\\cli\\bin\\nest.js'
]
}
This only happens with @nestjs/cli version to be 8.2.2
Minimum reproduction code
https://github.com/nestjs/typescript-starter.git
Steps to reproduce
- pull
https://github.com/nestjs/typescript-starter.gitrepo - run
npm updatewhich will bring dependencies to latest versions including@nestjs/cliversion to 8.2.2 - run
npm run build
FYI, the related sections in package.json after the npm update
{
"dependencies": {
"@nestjs/common": "^8.4.0",
"@nestjs/core": "^8.4.0",
"@nestjs/platform-express": "^8.4.0",
"reflect-metadata": "^0.1.13",
"rimraf": "^3.0.2",
"rxjs": "^7.5.4"
},
"devDependencies": {
"@nestjs/cli": "^8.2.2",
"@nestjs/schematics": "^8.0.7",
"@nestjs/testing": "^8.4.0",
"@types/express": "^4.17.13",
"@types/jest": "^27.4.1",
"@types/node": "^16.11.26",
"@types/supertest": "^2.0.11",
"@typescript-eslint/eslint-plugin": "^4.29.2",
"@typescript-eslint/parser": "^4.29.2",
"eslint": "^7.32.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^3.4.1",
"jest": "^27.5.1",
"prettier": "^2.5.1",
"source-map-support": "^0.5.21",
"supertest": "^6.2.2",
"ts-jest": "^27.1.3",
"ts-loader": "^9.2.7",
"ts-node": "^10.6.0",
"tsconfig-paths": "^3.13.0",
"typescript": "^4.6.2"
}
}
Expected behavior
successfully build
Package version
8.2.2
NestJS version
8.4.0
Node.js version
14.19.0 (x64) and 16.14.0 (x64)
In which operating systems have you tested?
- [ ] macOS
- [X] Windows
- [ ] Linux
Other
It will fix itself if drop @nests/cli to its previous version 8.2.1. Other dependencies can remain on the same versions.
I didn't manage to reproduce this on my Ubuntu
What I've done:
git clone https://github.com/nestjs/typescript-starter.git
cd typescript-starter
rm package-lock.json
npm i
npm run build
echo $? # 0
@micalevisk you need to run npm update to update dependency, the current typescript-starter is still using 8.1.3 for @nests/cli
actually, when we drop the lockfile, the latest version of @nestjs/cli will be instaled as it satisfies the semver range ^8.1.3
$ grep version node_modules/@nestjs/cli/package.json
"version": "8.2.2",
could you try those steps?
@steven-g-w could you run npm init nestjs to create a new app, and test this behavior against it instead of typescript-starter repo? The npm run build succeeded here as well
@micalevisk I guess it's an issue only on windows, I tried the steps (both yours and mine) on my macbook pro (intel) and it worked fine.
nvm, I believe the issue is on schema-utils package
See https://github.com/TypeStrong/fork-ts-checker-webpack-plugin/issues/706
humm right, so this is actually what breaks it: PR https://github.com/nestjs/nest-cli/pull/1532 Though it doesn't seem to be something we can fix?
right got it work with installing ajv-keywords as peer depenency manually. thanks! @micalevisk