Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@types/node Class 'Module' incorrectly implements interface 'NodeModule'. #19601

Closed
2 tasks done
egorshulga opened this issue Sep 7, 2017 · 20 comments
Closed
2 tasks done

Comments

@egorshulga
Copy link
Contributor

egorshulga commented Sep 7, 2017

  • I tried using the @types/node package and had problems.
  • Mention the authors (see Definitions by: in index.d.ts) so they can respond.

Compilation cannot succeed with the version 8.0.27 installed. The error is
node_modules/@types/node/index.d.ts(5615,11): error TS2420: Class 'Module' incorrectly implements interface 'NodeModule'. Property 'hot' is missing in type 'Module'.

Version 8.0.26 does not have this error.

@ldrick
Copy link
Contributor

ldrick commented Sep 7, 2017

Perfect, thanks, was quite in this moment writing the same issue. This seems to be an conflict with @types/webpack-env

@devoto13
Copy link
Contributor

devoto13 commented Sep 7, 2017

My guess would be that somewhere in the project you augment NodeModule definition by adding hot property in it. I added Module class, which implements NodeModule recently. and it obviously doesn't have this new property added because of the augmentation.

As a temporary fix you can either remove augmentation or add something like below (haven't actually tested it). Or just pin version to 8.0.26 until it's fixed.

(incorrect code removed)

I'll submit a PR to fix this issue soon.

devoto13 added a commit to devoto13/DefinitelyTyped that referenced this issue Sep 7, 2017
This causes type errors, when people augment NodeModule intefrace by
adding more properties to it. Which seems to be pretty common in a wild.

Fixes DefinitelyTyped#19601
molnarzs added a commit to garlictech/workflows that referenced this issue Sep 9, 2017
@burabure
Copy link

burabure commented Sep 13, 2017

still getting the same error. It seems you NEED to add @types/webpack-env to package.json in order to fix this

@ghost
Copy link

ghost commented Sep 14, 2017

@burabure The contents of your package.json shouldn't affect TypeScript -- although the contents of node_modules does. Having just @types/node installed without @types/webpack-env doesn't reproduce the error for me, nor does having both installed. Maybe you fixed your error by updating webpack-env?

@burabure
Copy link

burabure commented Sep 14, 2017

ok the issue was that another of my deps @types/storybook__react had a dependecy on the old @types/webpack-env

@micahgodbolt
Copy link

@burabure what was your solution. I'm in the same boat. Just remove webpack-env, as storybook will bring it in as a dependency?

@burabure
Copy link

@micahgodbolt I did yarn remove @types/node @types/storybook__react && yarn add -D @types/node @types/storybook__react but updating those might do the job also

@sentilesdal
Copy link
Contributor

@burabure, @micaelmbagira I was able to solve this problem by downgrading @types/webpack-env to 1.14.1.

@neilpoulin
Copy link
Contributor

I had this same issue, although with a slightly different error message. Downgrading to @types/webpack-env@1.14.1 as @sentilesdal suggested did the trick for me.

Below was my error when running tsc. This problem started after I added storybook to my project. I also ended up downgrading my Note types to @types/node@12.12.6. I'm not sure what specifically solved the problem, but with those two settings, I was able to get things working.

Here's the error:

node_modules/@types/webpack-env/index.d.ts:349:15 - error TS2430: Interface 'NodeJS.Module' incorrectly extends interface '__WebpackModuleApi.Module'.
  Types of property 'parent' are incompatible.
    Type 'Module | null' is not assignable to type 'NodeModule | null'.
      Type 'Module' is not assignable to type 'NodeModule'.
        Property 'hot' is optional in type 'Module' but required in type 'NodeModule'.
 

 
349     interface Module extends __WebpackModuleApi.Module {}

@sinoon
Copy link

sinoon commented Jul 7, 2020

for the get type error buddy, you can add "types": ["@types/node"] to project tsconfig.js, it means that only the type listed it will import in the type system.

@ferm10n
Copy link

ferm10n commented Sep 14, 2020

My team also ran into this issue, and downgrading @types/webpack-env did not help.

Instead, we were able to resolve it by rolling back @types/node@14.10.1 to @types/node@14.0.27

@sanex3339
Copy link
Contributor

Same problem with @types/node@14.10.1 and above

@Shinigami92
Copy link
Contributor

Having this problem with @types/node@14.10.1 but not with @types/node@14.10.0 !!!
Just a bugfix release turns out to be a breaking change 👀

@sandersn
Copy link
Contributor

DT piggy-backs on semver, so you should specify exact versions of @types packages:
https://github.com/DefinitelyTyped/DefinitelyTyped#how-do-definitely-typed-package-versions-relate-to-versions-of-the-corresponding-library

@ferm10n
Copy link

ferm10n commented Sep 16, 2020

@sandersn So maybe those of us who are affected should try to target the packages that use @types/node instead?

I could see that leading to having multiple installs of @types/node at slightly different versions, I'm not familiar enough with how these types are used to determine if that'd be an issue but I'd expect it to be fine.

g1eny0ung added a commit to seagreenio/react-bulma that referenced this issue Sep 17, 2020
@Shinigami92
Copy link
Contributor

Works again with 14.11.1 as if nothing had ever happened 🤷‍♂️

@cefjic
Copy link

cefjic commented Sep 21, 2020

I have the error Interface 'NodeJS.Module' incorrectly extends interface '__WebpackModuleApi.Module'. on v14.11.1

@ferm10n
Copy link

ferm10n commented Sep 21, 2020

What are the odds that there's different versions of the same package?

Here's an idea to help us figure things out. For anyone experiencing this problem currently and in future:

  • npm ci to do a clean install
  • verify the error is still present
  • comment and attach your project's package-lock and tsconfig (remove sensitive stuff if needed)

@tobilen
Copy link

tobilen commented Sep 22, 2020

Same issue with 14.11.2 in my project. Tried downgrading to 14.11.1 and then 14.11.0, same issue.

Working tree (including lockfile and package.json) -> https://github.com/ivx/react-skeletons/tree/d3ffc9fbbcf3f7c08a230e9c287a55b53d785ac7
CI Result: https://app.circleci.com/pipelines/github/ivx/react-skeletons/83/workflows/11182212-cb51-432b-9653-cf5cca0f22eb/jobs/216

Resolved it by removing @types/node since i didn't need it anymore. Output of yarn why @types/node might be interesting:

$ yarn why @types/node
yarn why v1.22.4
[1/4] Why do we have the module "@types/node"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "@types/node@14.11.0"
info Has been hoisted to "@types/node"
info This module exists because it's specified in "devDependencies".
info Disk size without dependencies: "824KB"
info Disk size with unique dependencies: "824KB"
info Disk size with transitive dependencies: "824KB"
info Number of shared dependencies: 0
=> Found "@jest/types#@types/node@13.13.5"
info This module exists because "@jest#types" depends on it.
info Disk size without dependencies: "820KB"
info Disk size with unique dependencies: "820KB"
info Disk size with transitive dependencies: "820KB"
info Number of shared dependencies: 0
=> Found "@jest/core#@types/node@13.13.5"
info This module exists because "jest#@jest#core" depends on it.
info Disk size without dependencies: "820KB"
info Disk size with unique dependencies: "820KB"
info Disk size with transitive dependencies: "820KB"
info Number of shared dependencies: 0
=> Found "jest-util#@types/node@13.13.5"
info This module exists because "ts-jest#jest-util" depends on it.
info Disk size without dependencies: "820KB"
info Disk size with unique dependencies: "820KB"
info Disk size with transitive dependencies: "820KB"
info Number of shared dependencies: 0
=> Found "@jest/console#@types/node@13.13.5"
info This module exists because "jest#@jest#core#@jest#console" depends on it.
info Disk size without dependencies: "820KB"
info Disk size with unique dependencies: "820KB"
info Disk size with transitive dependencies: "820KB"
info Number of shared dependencies: 0
=> Found "@types/node-fetch#@types/node@13.13.5"
info This module exists because "@storybook#react#@storybook#core#@types#node-fetch" depends on it.
info Disk size without dependencies: "820KB"
info Disk size with unique dependencies: "820KB"
info Disk size with transitive dependencies: "820KB"
info Number of shared dependencies: 0
=> Found "jest-haste-map#@types/node@13.13.5"
info This module exists because "jest#@jest#core#jest-haste-map" depends on it.
info Disk size without dependencies: "820KB"
info Disk size with unique dependencies: "820KB"
info Disk size with transitive dependencies: "820KB"
info Number of shared dependencies: 0
=> Found "jest-runner#@types/node@13.13.5"
info This module exists because "jest#@jest#core#jest-runner" depends on it.
info Disk size without dependencies: "820KB"
info Disk size with unique dependencies: "820KB"
info Disk size with transitive dependencies: "820KB"
info Number of shared dependencies: 0
=> Found "jest-watcher#@types/node@13.13.5"
info This module exists because "jest#@jest#core#jest-watcher" depends on it.
info Disk size without dependencies: "820KB"
info Disk size with unique dependencies: "820KB"
info Disk size with transitive dependencies: "820KB"
info Number of shared dependencies: 0
=> Found "@jest/environment#@types/node@13.13.5"
info This module exists because "jest#@jest#core#jest-runner#@jest#environment" depends on it.
info Disk size without dependencies: "820KB"
info Disk size with unique dependencies: "820KB"
info Disk size with transitive dependencies: "820KB"
info Number of shared dependencies: 0
=> Found "@jest/fake-timers#@types/node@13.13.5"
info This module exists because "jest#@jest#core#jest-runtime#@jest#fake-timers" depends on it.
info Disk size without dependencies: "820KB"
info Disk size with unique dependencies: "820KB"
info Disk size with transitive dependencies: "820KB"
info Number of shared dependencies: 0
=> Found "@types/glob#@types/node@13.13.5"
info This module exists because "@storybook#react#@storybook#core#glob-promise#@types#glob" depends on it.
info Disk size without dependencies: "820KB"
info Disk size with unique dependencies: "820KB"
info Disk size with transitive dependencies: "820KB"
info Number of shared dependencies: 0
=> Found "@types/graceful-fs#@types/node@13.13.5"
info This module exists because "jest#@jest#core#jest-haste-map#@types#graceful-fs" depends on it.
info Disk size without dependencies: "820KB"
info Disk size with unique dependencies: "820KB"
info Disk size with transitive dependencies: "820KB"
info Number of shared dependencies: 0
=> Found "@types/webpack#@types/node@13.13.5"
info This module exists because "@storybook#react#@storybook#core#html-webpack-plugin#@types#webpack" depends on it.
info Disk size without dependencies: "820KB"
info Disk size with unique dependencies: "820KB"
info Disk size with transitive dependencies: "820KB"
info Number of shared dependencies: 0
=> Found "jest-environment-jsdom#@types/node@13.13.5"
info This module exists because "jest#@jest#core#jest-config#jest-environment-jsdom" depends on it.
info Disk size without dependencies: "820KB"
info Disk size with unique dependencies: "820KB"
info Disk size with transitive dependencies: "820KB"
info Number of shared dependencies: 0
=> Found "jest-environment-node#@types/node@13.13.5"
info This module exists because "jest#@jest#core#jest-config#jest-environment-node" depends on it.
info Disk size without dependencies: "820KB"
info Disk size with unique dependencies: "820KB"
info Disk size with transitive dependencies: "820KB"
info Number of shared dependencies: 0
=> Found "jest-jasmine2#@types/node@13.13.5"
info This module exists because "jest#@jest#core#jest-config#jest-jasmine2" depends on it.
info Disk size without dependencies: "820KB"
info Disk size with unique dependencies: "820KB"
info Disk size with transitive dependencies: "820KB"
info Number of shared dependencies: 0
=> Found "jest-mock#@types/node@13.13.5"
info This module exists because "jest#@jest#core#jest-runtime#jest-mock" depends on it.
info Disk size without dependencies: "820KB"
info Disk size with unique dependencies: "820KB"
info Disk size with transitive dependencies: "820KB"
info Number of shared dependencies: 0
=> Found "jest-serializer#@types/node@13.13.5"
info This module exists because "jest#@jest#core#jest-haste-map#jest-serializer" depends on it.
info Disk size without dependencies: "820KB"
info Disk size with unique dependencies: "820KB"
info Disk size with transitive dependencies: "820KB"
info Number of shared dependencies: 0
=> Found "jest-worker#@types/node@13.13.5"
info This module exists because "@storybook#react#@storybook#core#terser-webpack-plugin#jest-worker" depends on it.
info Disk size without dependencies: "820KB"
info Disk size with unique dependencies: "820KB"
info Disk size with transitive dependencies: "820KB"
info Number of shared dependencies: 0
=> Found "@types/webpack-sources#@types/node@13.13.5"
info This module exists because "@storybook#react#@storybook#core#html-webpack-plugin#@types#webpack#@types#webpack-sources" depends on it.
info Disk size without dependencies: "820KB"
info Disk size with unique dependencies: "820KB"
info Disk size with transitive dependencies: "820KB"
info Number of shared dependencies: 0
Done in 0.55s.

@Elvin1492
Copy link

The solution which is worked for me

  • npm ci
  • downgrade version ->npm i @types@{your version}
  • npm cache clean

Done

g1eny0ung added a commit to seagreenio/react-bulma that referenced this issue Feb 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests