Closed jagomf closed 5 years ago
I have the same issue. The same code was ok last friday.
Same issue w/ Node v9.5.0
I change type/webpack to '^3.0.0' and it works. But the Type definitions for tapable becomes v0.2.5...
npm install @types/tapable --save-dev
solves this issue.
This appears to be a result of @types/webpack
aggressively getting @types/tapable
latest version 1.0.0.
From @types/webpack
(2.2.16) package.json:
"dependencies": {
"@types/node": "*",
"@types/tapable": "*",
"@types/uglify-js": "*"
},
Which would resolve to semver 1.0.0 according to the list of releases, but as noted above, the "compatible" working version is 0.2.5. When specifying 0.2.5 manually, it works, and the version specification must have been fixed in a more recent version of @types/webpack
according to @Brunoon.
following up on @jesion
npm install @types/tapable@0.2.5 --save-dev
fixes the issue
You can use @types/tapable
or tapable@2
(when available) to solve the type issues.
try to add process.traceDeprecation = true;
in webpack.config.js
ref: https://mutter.monotalk.xyz/posts/c5611095ba5bd8d824b3a76359650141 https://stackoverflow.com/questions/42918250/process-tracedeprecation-not-working-in-webpack-config
If anyone has wasted an hour on this like me, do the following. This is the only thing that worked for me: add this to your build process to disable typescript check for that file:
sed -i '1s/^/\/\/ @ts-nocheck\n/' node_modules/@types/webpack/index.d.ts
The reason this issue happens is that webpack4 is somewhat an old library already and it depends on older version of tapable@1.x.x
(and tapable@1.x.x
doesn't have its own typings thus there is a ./node_modules/@types/tapable
package installed). Most npm packages today depend on newer version of tapable@2.x.x
which ships with its own typings. The problem happens when inside @types/webpack
(old typings for webpack4) webpack4 imports something from tapable
and because we have newer version of tapable
installed webpack4 gets its tapable
typings not out of the old version (./node_modules/@types/tapable
) but from the newer version which has its own typings inside ./node_modules/tapable
and the older typings for tapable (./node_modules/@types/tapable
) simply get ignored.
The reason solution above works is because when we install very very very old version of @types/tapable@0.2.5
we force npm to move the typings for tapable
that webpack4 needs from ./node_modules/@types/tapable
into the node_modules of webpack4 making webpack4 pick up the legacy typings for tapable
from its own node_modules (./node_modules/@types/webpack/node_modules/@types/tapable
) instead of the newer ones from ./node_modules/tapable
.
I think a much better solution would be to install the current version of @types/tapable
package instead of installing very old and deprecated version, simply run this command:
npm i -D @types/tapable
The effect is going to be absolutely the same except now you get an up-to-date version of the @types/tapable
package which, you might have guessed already, simply re-exports the tapable
package because nowadays tapable
has its own type definitions.
I got this issue when I was installing storybook because storybook still uses webpack4 for some reason. Hopefully in the future they move to webpack5 and this issue disappears altogether.
Thank you, good night
I'm getting these errors upon building my project: