nestjs / nest

A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
https://nestjs.com
MIT License
67.62k stars 7.61k forks source link

Latest NestJS CLI generated project cannot build due to webpack & Tapable type errors #6758

Closed sannajammeh closed 3 years ago

sannajammeh commented 3 years ago

Bug Report

Something has broken while preparing for production deployment. Due to other reasons, I had to delete my yarn lock file and I started getting error messages. It builds just fine in development, however, it displays over 90 errors of missing @types packages from @types/webpack and @types/tapable. This breaks the production build. I've tried reinstalling packages with npm and yarn, deleting node_modules, lock files, and also removing the yarn cache, all to no avail. I thought there was something wrong with my project so I created a new test project with the NestJS CLI and the latest version, still the same issue.

Current behavior

Below is the complete error message I receive in my console when running npm run build:

> nest build

node_modules/@types/tapable/index.d.ts:7:15 - error TS2307: Cannot find module '
./node_modules/tapable' or its corresponding type declarations.

7 export * from './node_modules/tapable';
                ~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:32:3 - error TS2305: Module '"tapable"' h
as no exported member 'Tapable'.

32   Tapable,
     ~~~~~~~
node_modules/@types/webpack/index.d.ts:1062:23 - error TS2707: Generic type 'Syn
cWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.

1062             resolver: SyncWaterfallHook;
                           ~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1063:22 - error TS2707: Generic type 'Syn
cWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.

1063             factory: SyncWaterfallHook;
                          ~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1064:28 - error TS2707: Generic type 'Asy
ncSeriesWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type argum
ents.

1064             beforeResolve: AsyncSeriesWaterfallHook;
                                ~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1065:27 - error TS2707: Generic type 'Asy
ncSeriesWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type argum
ents.

1065             afterResolve: AsyncSeriesWaterfallHook;
                               ~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1066:27 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1066             createModule: SyncBailHook;
                               ~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1067:21 - error TS2707: Generic type 'Syn
cWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.

1067             module: SyncWaterfallHook;
                         ~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1068:27 - error TS2314: Generic type 'Hoo
kMap<H>' requires 1 type argument(s).

1068             createParser: HookMap;
                               ~~~~~~~
node_modules/@types/webpack/index.d.ts:1070:30 - error TS2314: Generic type 'Hoo
kMap<H>' requires 1 type argument(s).

1070             createGenerator: HookMap;
                                  ~~~~~~~
node_modules/@types/webpack/index.d.ts:1071:24 - error TS2314: Generic type 'Hoo
kMap<H>' requires 1 type argument(s).

1071             generator: HookMap;
                            ~~~~~~~
node_modules/@types/webpack/index.d.ts:1080:33 - error TS2314: Generic type 'Hoo
kMap<H>' requires 1 type argument(s).

1080                 evaluateTypeof: HookMap;
                                     ~~~~~~~
node_modules/@types/webpack/index.d.ts:1081:27 - error TS2314: Generic type 'Hoo
kMap<H>' requires 1 type argument(s).

1081                 evaluate: HookMap;
                               ~~~~~~~
node_modules/@types/webpack/index.d.ts:1082:37 - error TS2314: Generic type 'Hoo
kMap<H>' requires 1 type argument(s).

1082                 evaluateIdentifier: HookMap;
                                         ~~~~~~~
node_modules/@types/webpack/index.d.ts:1083:44 - error TS2314: Generic type 'Hoo
kMap<H>' requires 1 type argument(s).

1083                 evaluateDefinedIdentifier: HookMap;
                                                ~~~~~~~
node_modules/@types/webpack/index.d.ts:1084:47 - error TS2314: Generic type 'Hoo
kMap<H>' requires 1 type argument(s).

1084                 evaluateCallExpressionMember: HookMap;
                                                   ~~~~~~~
node_modules/@types/webpack/index.d.ts:1085:28 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1085                 statement: SyncBailHook;
                                ~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1086:30 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1086                 statementIf: SyncBailHook;
                                  ~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1087:24 - error TS2314: Generic type 'Hoo
kMap<H>' requires 1 type argument(s).

1087                 label: HookMap;
                            ~~~~~~~
node_modules/@types/webpack/index.d.ts:1088:25 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1088                 import: SyncBailHook;
                             ~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1089:34 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1089                 importSpecifier: SyncBailHook;
                                      ~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1090:25 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1090                 export: SyncBailHook;
                             ~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1091:31 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1091                 exportImport: SyncBailHook;
                                   ~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1092:36 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1092                 exportDeclaration: SyncBailHook;
                                        ~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1093:35 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1093                 exportExpression: SyncBailHook;
                                       ~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1094:34 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1094                 exportSpecifier: SyncBailHook;
                                      ~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1095:40 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1095                 exportImportSpecifier: SyncBailHook;
                                            ~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1096:33 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1096                 varDeclaration: SyncBailHook;
                                     ~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1097:36 - error TS2314: Generic type 'Hoo
kMap<H>' requires 1 type argument(s).

1097                 varDeclarationLet: HookMap;
                                        ~~~~~~~
node_modules/@types/webpack/index.d.ts:1098:38 - error TS2314: Generic type 'Hoo
kMap<H>' requires 1 type argument(s).

1098                 varDeclarationConst: HookMap;
                                          ~~~~~~~
node_modules/@types/webpack/index.d.ts:1099:36 - error TS2314: Generic type 'Hoo
kMap<H>' requires 1 type argument(s).

1099                 varDeclarationVar: HookMap;
                                        ~~~~~~~
node_modules/@types/webpack/index.d.ts:1100:28 - error TS2314: Generic type 'Hoo
kMap<H>' requires 1 type argument(s).

1100                 canRename: HookMap;
                                ~~~~~~~
node_modules/@types/webpack/index.d.ts:1101:25 - error TS2314: Generic type 'Hoo
kMap<H>' requires 1 type argument(s).

1101                 rename: HookMap;
                             ~~~~~~~
node_modules/@types/webpack/index.d.ts:1102:27 - error TS2314: Generic type 'Hoo
kMap<H>' requires 1 type argument(s).

1102                 assigned: HookMap;
                               ~~~~~~~
node_modules/@types/webpack/index.d.ts:1103:25 - error TS2314: Generic type 'Hoo
kMap<H>' requires 1 type argument(s).

1103                 typeof: HookMap;
                             ~~~~~~~
node_modules/@types/webpack/index.d.ts:1104:29 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1104                 importCall: SyncBailHook;
                                 ~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1105:23 - error TS2314: Generic type 'Hoo
kMap<H>' requires 1 type argument(s).

1105                 call: HookMap;
                           ~~~~~~~
node_modules/@types/webpack/index.d.ts:1106:32 - error TS2314: Generic type 'Hoo
kMap<H>' requires 1 type argument(s).

1106                 callAnyMember: HookMap;
                                    ~~~~~~~
node_modules/@types/webpack/index.d.ts:1107:22 - error TS2314: Generic type 'Hoo
kMap<H>' requires 1 type argument(s).

1107                 new: HookMap;
                          ~~~~~~~
node_modules/@types/webpack/index.d.ts:1108:29 - error TS2314: Generic type 'Hoo
kMap<H>' requires 1 type argument(s).

1108                 expression: HookMap;
                                 ~~~~~~~
node_modules/@types/webpack/index.d.ts:1109:38 - error TS2314: Generic type 'Hoo
kMap<H>' requires 1 type argument(s).

1109                 expressionAnyMember: HookMap;
                                          ~~~~~~~
node_modules/@types/webpack/index.d.ts:1110:48 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1110                 expressionConditionalOperator: SyncBailHook;
                                                    ~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1111:44 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1111                 expressionLogicalOperator: SyncBailHook;
                                                ~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1112:26 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1112                 program: SyncBailHook;
                              ~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1121:28 - error TS2707: Generic type 'Asy
ncSeriesWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type argum
ents.

1121             beforeResolve: AsyncSeriesWaterfallHook;
                                ~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1122:27 - error TS2707: Generic type 'Asy
ncSeriesWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type argum
ents.

1122             afterResolve: AsyncSeriesWaterfallHook;
                               ~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1123:33 - error TS2707: Generic type 'Syn
cWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.

1123             contextModuleFiles: SyncWaterfallHook;
                                     ~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1124:27 - error TS2707: Generic type 'Asy
ncSeriesWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type argum
ents.

1124             alternatives: AsyncSeriesWaterfallHook;
                               ~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1144:21 - error TS2707: Generic type 'Syn
cHook<T, R, AdditionalOptions>' requires between 1 and 3 type arguments.

1144             unseal: SyncHook;
                         ~~~~~~~~
node_modules/@types/webpack/index.d.ts:1145:19 - error TS2707: Generic type 'Syn
cHook<T, R, AdditionalOptions>' requires between 1 and 3 type arguments.

1145             seal: SyncHook;
                       ~~~~~~~~
node_modules/@types/webpack/index.d.ts:1147:40 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1147             optimizeDependenciesBasic: SyncBailHook<Module[]>;
                                            ~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1148:35 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1148             optimizeDependencies: SyncBailHook<Module[]>;
                                       ~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1149:43 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1149             optimizeDependenciesAdvanced: SyncBailHook<Module[]>;
                                               ~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1152:23 - error TS2707: Generic type 'Syn
cHook<T, R, AdditionalOptions>' requires between 1 and 3 type arguments.

1152             optimize: SyncHook;
                           ~~~~~~~~
node_modules/@types/webpack/index.d.ts:1154:35 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1154             optimizeModulesBasic: SyncBailHook<Module[]>;
                                       ~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1155:30 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1155             optimizeModules: SyncBailHook<Module[]>;
                                  ~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1156:38 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1156             optimizeModulesAdvanced: SyncBailHook<Module[]>;
                                          ~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1171:27 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1171             shouldRecord: SyncBailHook;
                               ~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1190:25 - error TS2707: Generic type 'Syn
cHook<T, R, AdditionalOptions>' requires between 1 and 3 type arguments.

1190             beforeHash: SyncHook;
                             ~~~~~~~~
node_modules/@types/webpack/index.d.ts:1191:24 - error TS2707: Generic type 'Syn
cHook<T, R, AdditionalOptions>' requires between 1 and 3 type arguments.

1191             afterHash: SyncHook;
                            ~~~~~~~~
node_modules/@types/webpack/index.d.ts:1197:33 - error TS2707: Generic type 'Syn
cHook<T, R, AdditionalOptions>' requires between 1 and 3 type arguments.

1197             beforeModuleAssets: SyncHook;
                                     ~~~~~~~~
node_modules/@types/webpack/index.d.ts:1198:40 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1198             shouldGenerateChunkAssets: SyncBailHook;
                                            ~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1199:32 - error TS2707: Generic type 'Syn
cHook<T, R, AdditionalOptions>' requires between 1 and 3 type arguments.

1199             beforeChunkAssets: SyncHook;
                                    ~~~~~~~~
node_modules/@types/webpack/index.d.ts:1204:31 - error TS2707: Generic type 'Asy
ncSeriesHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.

1204             additionalAssets: AsyncSeriesHook;
                                   ~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1210:33 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1210             needAdditionalSeal: SyncBailHook;
                                     ~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1211:24 - error TS2707: Generic type 'Asy
ncSeriesHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.

1211             afterSeal: AsyncSeriesHook;
                            ~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1219:33 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1219             needAdditionalPass: SyncBailHook;
                                     ~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1220:28 - error TS2707: Generic type 'Syn
cHook<T, R, AdditionalOptions>' requires between 1 and 3 type arguments.

1220             childCompiler: SyncHook;
                                ~~~~~~~~
node_modules/@types/webpack/index.d.ts:1224:43 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1224             optimizeExtractedChunksBasic: SyncBailHook<Chunk[]>;
                                               ~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1225:38 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1225             optimizeExtractedChunks: SyncBailHook<Chunk[]>;
                                          ~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1226:46 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1226             optimizeExtractedChunksAdvanced: SyncBailHook<Chunk[]>;
                                                  ~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1239:27 - error TS2707: Generic type 'Syn
cWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.

1239             jsonpScript?: SyncWaterfallHook<string, Chunk, string>;
                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1240:22 - error TS2707: Generic type 'Syn
cWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.

1240             require: SyncWaterfallHook<string, Chunk, string>;
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1241:32 - error TS2707: Generic type 'Syn
cWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.

1241             requireExtensions: SyncWaterfallHook<string, Chunk, string>;
                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1242:28 - error TS2707: Generic type 'Syn
cWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.

1242             requireEnsure: SyncWaterfallHook<string, Chunk, string>;
                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1243:24 - error TS2707: Generic type 'Syn
cWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.

1243             localVars: SyncWaterfallHook<string, Chunk, string>;
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1244:27 - error TS2707: Generic type 'Syn
cWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.

1244             afterStartup: SyncWaterfallHook<string, Chunk, string>;
                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1258:22 - error TS2707: Generic type 'Syn
cWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.

1258             content: SyncWaterfallHook;
                          ~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1259:21 - error TS2707: Generic type 'Syn
cWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.

1259             module: SyncWaterfallHook;
                         ~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1260:21 - error TS2707: Generic type 'Syn
cWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.

1260             render: SyncWaterfallHook;
                         ~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1261:22 - error TS2707: Generic type 'Syn
cWaterfallHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.

1261             package: SyncWaterfallHook;
                          ~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1262:19 - error TS2707: Generic type 'Syn
cHook<T, R, AdditionalOptions>' requires between 1 and 3 type arguments.

1262             hash: SyncHook;
                       ~~~~~~~~
node_modules/@types/webpack/index.d.ts:1356:25 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1356             shouldEmit: SyncBailHook<Compilation>;
                             ~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1358:29 - error TS2707: Generic type 'Asy
ncSeriesHook<T, AdditionalOptions>' requires between 1 and 2 type arguments.

1358             additionalPass: AsyncSeriesHook;
                                 ~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1374:25 - error TS2707: Generic type 'Syn
cHook<T, R, AdditionalOptions>' requires between 1 and 3 type arguments.

1374             watchClose: SyncHook;
                             ~~~~~~~~
node_modules/@types/webpack/index.d.ts:1375:26 - error TS2707: Generic type 'Syn
cHook<T, R, AdditionalOptions>' requires between 1 and 3 type arguments.

1375             environment: SyncHook;
                              ~~~~~~~~
node_modules/@types/webpack/index.d.ts:1376:31 - error TS2707: Generic type 'Syn
cHook<T, R, AdditionalOptions>' requires between 1 and 3 type arguments.

1376             afterEnvironment: SyncHook;
                                   ~~~~~~~~
node_modules/@types/webpack/index.d.ts:1379:26 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1379             entryOption: SyncBailHook;
                              ~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:1399:25 - error TS2707: Generic type 'Syn
cHook<T, R, AdditionalOptions>' requires between 1 and 3 type arguments.

1399             watchClose: SyncHook;
                             ~~~~~~~~
node_modules/@types/webpack/index.d.ts:1466:24 - error TS2707: Generic type 'Syn
cBailHook<T, R, AdditionalOptions>' requires between 2 and 3 type arguments.

1466         _pluginCompat: SyncBailHook<compilation.Compilation>;
                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 90 error(s).

npm ERR! code 1
npm ERR! path C:\htdocs\sandbox\fansify-test
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c nest build

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\TFKPromo\AppData\Local\npm-cache\_logs\2021-03-26T04_21_31
_071Z-debug.log

Input Code

Reproduce: install the latest nestjs cli and creat a new project, CD into the folder and run npm install && npm run build

Expected behavior

Should build fine without any type errors due to missing dependencies.

Possible Solution

Environment


Nest version: latest

For Tooling issues:
- Node version: 15.5.0 
- Platform:  Windows

Others:
Both npm and yarn faces this problem.
jmcdo29 commented 3 years ago

@types/tapable was updated today and breaks @types/webpack which is a dependency of @nestjs/cli. There's not much Nest can do about this, as the @types/webpack uses the most recent version of @types/tapable.

ghost commented 3 years ago

same issue..

jmcdo29 commented 3 years ago

Again, there's nothing nest can really do about this. The @types/webpack repository needs to be informed of the issue and have their version pinned rather than using the most recent. Then we can pin our @types/webpack version and fix the issue

Gwash3189 commented 3 years ago

Hi! Thanks for the clarification @jmcdo29. Your comment took me to the @types repository, and this PR specifically. It looks like it could be related.

After running npm install in a new nestjs project and looking at the package-lock.json, It looks like it could be that nestjs installs "@types/webpack": "4.41.26" but uses "webpack": "5.11.0".

Running npm install --save-dev @types/webpack to get the latest webpack types fixes the majority of the type issues.

The remaining errors come from the @types/webpack and @types/tapable directly. The errors are:

> nest build

node_modules/@types/tapable/index.d.ts:7:15 - error TS2307: Cannot find module './node_modules/tapable' or its corresponding type declarations.

7 export * from './node_modules/tapable';
                ~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@types/webpack/index.d.ts:29:26 - error TS2307: Cannot find module './node_modules/webpack' or its corresponding type declarations.

29 import webpack = require('./node_modules/webpack');
                            ~~~~~~~~~~~~~~~~~~~~~~~~

Found 2 error(s).

I'm a little unfamiliar with @types and how the webpack and tapable libraries seem to be re-exporting their own webpack and tapable dependencies, rather than the ones resolved by node.

MichaelMarner commented 3 years ago

It looks like new types that are included with both webpack and tapable are clashing with the versions provided by DefinitelyTyped.

npm uninstall --save @types/webpack @types/tapable

Seems to fix the issue for me. So maybe just need to update the package.json template to not include them?

LucidDan commented 3 years ago

It looks like new types that are included with both webpack and tapable are clashing with the versions provided by DefinitelyTyped.

npm uninstall --save @types/webpack @types/tapable

Seems to fix the issue for me. So maybe just need to update the package.json template to not include them?

Simply uninstalling those packages did not help for me. I ran into this problem today while setting up the typescript-starter project and trying out for the first time with NestJS (terrible timing, for a minute I thought NestJS was awful and I'd made a horrible mistake haha..eventually figured out its an upstream issue and totally not NestJS fault).

In any case, for me I managed to work around this issue by doing the following in the https://github.com/nestjs/typescript-starter project:

yarn add tapable@1.1.3
yarn add -D @types/webpack # (which installed v5.0.0 of @types/webpack)

I'm now at least able to start Nest and start playing around with it, but beware anyone that uses this workaround; given I literally took my first look at NestJS today, this was brute-force solved via trial and error, and I might've missed something important.

Hanggi commented 3 years ago

It looks like new types that are included with both webpack and tapable are clashing with the versions provided by DefinitelyTyped.

npm uninstall --save @types/webpack @types/tapable

Seems to fix the issue for me. So maybe just need to update the package.json template to not include them?

Simply uninstalling those packages did not help for me. I ran into this problem today while setting up the typescript-starter project and trying out for the first time with NestJS (terrible timing, for a minute I thought NestJS was awful and I'd made a horrible mistake haha..eventually figured out its an upstream issue and totally not NestJS fault).

In any case, for me I managed to work around this issue by doing the following in the https://github.com/nestjs/typescript-starter project:

yarn add tapable@1.1.3
yarn add -D @types/webpack # (which installed v5.0.0 of @types/webpack)

I'm now at least able to start Nest and start playing around with it, but beware anyone that uses this workaround; given I literally took my first look at NestJS today, this was brute-force solved via trial and error, and I might've missed something important.

It works for me.

mersanuzun commented 3 years ago

It worked with these versions for me

npm i @types/webpack@4.41.27 npm i tapable@1.1.3

hckafadar commented 3 years ago

It worked with these versions for me

npm i @types/webpack@4.41.27 npm i tapable@1.1.3

It works for me

kamilmysliwiec commented 3 years ago

https://github.com/nestjs/nest/issues/6764#issuecomment-808056980