Definitelytyped: @types/node Class 'Module' incorrectly implements interface 'NodeModule'.

Created on 7 Sep 2017  ·  19Comments  ·  Source: DefinitelyTyped/DefinitelyTyped

  • [x] I tried using the @types/node package and had problems.
  • [x] [Mention](https://github.com/blog/821-mention-somebody-they-re-notified) the authors (see Definitions by: in index.d.ts) so they can respond.

    • Authors: @devoto13, @andy-ms

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.

Most helpful comment

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/[email protected] to @types/[email protected]

All 19 comments

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

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.

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

@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?

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

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

@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

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

I had this same issue, although with a slightly different error message. Downgrading to @types/[email protected] 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/[email protected]. 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 {}
```

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.

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/[email protected] to @types/[email protected]

Same problem with @types/[email protected] and above

Having this problem with @types/[email protected] but not with @types/[email protected] !!!
Just a bugfix release turns out to be a breaking change :eyes:

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

@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.

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

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

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)

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/[email protected]"
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/[email protected]"
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/[email protected]"
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/[email protected]"
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/[email protected]"
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/[email protected]"
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/[email protected]"
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/[email protected]"
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/[email protected]"
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/[email protected]"
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/[email protected]"
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/[email protected]"
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/[email protected]"
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/[email protected]"
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/[email protected]"
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/[email protected]"
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/[email protected]"
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/[email protected]"
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/[email protected]"
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/[email protected]"
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/[email protected]"
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.
Was this page helpful?
0 / 5 - 0 ratings