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.

[Bug] [MODULE_NOT_FOUND] error for @types package when using webpack.config.ts

See original GitHub issue
  • I’d be willing to implement a fix

Describe the bug

Getting lots of error for types packages on yarn 2.1.1 When using TS file as webpack configuration. https://webpack.js.org/configuration/configuration-languages/#typescript

(node:67829) [MODULE_NOT_FOUND] Error: @types/react-dom tried to access react, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

To Reproduce

I’ve setup a repo that can reproduce this issue.

https://github.com/missing1984/yarn2-webpack-ts

run yarn && yarn build you would be able to see the warning.

Environment if relevant (please complete the following information):

  • OS: OSX
  • Node version 12
  • Yarn version 2.1.1

pnpFallbackMode: “dependencies-only”

Additional context

See discord discussion.

https://discord.com/channels/226791405589233664/654372321225605128/733439592614592604

Add any other context about the problem here.

looks like webpack-cli internally invoke ts-node to transpile configurations. I am not sure if this is a valid use case for pnp…

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
merceyzcommented, Aug 24, 2020
1reaction
RuniBrcommented, Jul 21, 2020

Am getting similar warning messages on 2.1 as well as after yarn set version from sources, but in my case it only appears when running jest or eslint

(node:7830) [MODULE_NOT_FOUND] Error: eslint-plugin-prettier tried to access eslint-config-prettier, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:7830) [MODULE_NOT_FOUND] Error: eslint-module-utils tried to access eslint-import-resolver-typescript, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:545) [MODULE_NOT_FOUND] Error: @types/enzyme tried to access react, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:545) [MODULE_NOT_FOUND] Error: @types/enzyme-adapter-react-16 tried to access enzyme, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:545) [MODULE_NOT_FOUND] Error: @types/react-dom tried to access react, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:545) [MODULE_NOT_FOUND] Error: @types/styled-components tried to access react, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.
(node:545) [MODULE_NOT_FOUND] Error: @types/hoist-non-react-statics tried to access react, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

FWIW: prior to updating the repo’s Yarn 2 version/source, the last commit in the version we were using was on the 25th of June. So something in between the 25th of June and Yarn 2.1’s release date (9th of July?) introduced these warning messages.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Typescript Module not found Can't resolve - Stack Overflow
My IDE resolves these interfaces fine but webpack always sends the following error. I tried different things but can't get that one to...
Read more >
webpack-dev-server - npm
Start using webpack-dev-server in your project by running `npm i ... TypeScript icon, indicating that this package has built-in type ...
Read more >
Package exports - webpack
When the exports field is specified, only these module requests are available. Any other requests will lead to a ModuleNotFound Error.
Read more >
can't resolve 'fs' webpack 5 | The AI Search Engine You Control
Module not found : Error: Can't resolve 'fs' with webpack ... Add "node": { "fs": "empty" } field in your webpack.config.js . ......
Read more >
Troubleshooting Issues with the TypeScript SDK
Workflow Errors are reflected in Temporal Web; Worker errors and logs are reflected ... When you pass a workflowsPath , our Webpack config...
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