question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

(react) TS2591: Cannot find name 'require'. Do you need to install type definitions for node? Try `npm i @types/node` and then add `node` to the types field in your tsconfig.

See original GitHub issue

Please make sure you have read the submission guidelines before posting an issue

Prerequisites

Please answer the following questions for yourself before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.

  • I am running the latest version
  • I checked the documentation (nx.dev) and found no answer
  • I checked to make sure that this issue has not already been filed
  • I’m reporting the issue to the correct repository (not related to React, Angular or any dependency)

Failure Information (for bugs)

I’m getting this error: TS2591: Cannot find name ‘require’. Do you need to install type definitions for node? Try npm i @types/node and then add node to the types field in your tsconfig.

I had types “node” in tsconfig intalled package etc.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:2
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

12reactions
codeninjacommented, Oct 9, 2021

Hey just in case anyone needs to solve this in the future:

Make sure you update the tsconfig.lib.json as well as the tsconfig.json inside the lib.

The tsconfig.lib.json in my project had an empty "types":[] which was overwriting the tsconfig.json’s types declaration!

image

5reactions
yeomanncommented, Jan 17, 2021

image

This is a fresh project and getting this error

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeScript getting error TS2304: cannot find name ' require'
Do you need to install type definitions for node? Try npm i @types/node and then add node to the types field in your...
Read more >
Cannot find name 'require' Error in TypeScript | bobbyhadz
To solve the "Cannot find name require" error, install the node types by running npm i -D @types/node . If the error is...
Read more >
Fix the Cannot Find Name 'require' Error in TypeScript
To fix the “cannot find name 'require'” error in TypeScript, install the @types/node package into your project by running npm i -D ...
Read more >
cannot find name 'require', Do you need to install ... - YouTube
cannot find name ' require ', Do you need to install type definitions for node ? Try ' npm install --save-dev @ types/node...
Read more >
cannot find name 'require'. do you need to install type ...
do you need to install type definitions for node? try `npm i --save-dev @types/node` and then add 'node' to the types field in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found