Webpack and Typescript, v2.3.0 Error: Can't resolve 'react'
See original GitHub issueI’m using Webpack 3 and Typescript, and I have been including instantsearch.js
in my files like so:
import * as instantsearch from 'instantsearch.js';
This has been working fine.
I recently tried upgrading from 2.0.2
to 2.3.0
and I followed your es6 example in your v2 documentation:
import instantsearch from 'instantsearch.js/es';
import { searchBox } from 'instantsearch.js/es/widgets';
const search = instantsearch(/* parameters */);
search.addWidget(
searchBox({
container: '#search-input'
})
);
However I am running into trouble. I get the following errors when I try initializing a widget.
ERROR in ./node_modules/instantsearch.js/es/components/MenuSelect.js
Module not found: Error: Can't resolve 'react' in 'C:\Users\mattucci\Documents\Visual-Studio-2017\Projects\Ontariocolleges\Ontariocolleges\node_modules\instantsearch.js\es\components'
@ ./node_modules/instantsearch.js/es/components/MenuSelect.js 11:0-41
@ ./node_modules/instantsearch.js/es/widgets/menu-select/menu-select.js
@ ./node_modules/instantsearch.js/es/widgets/index.js
@ ./Content/Scripts/search/search-programs-instantsearch.ts
@ ./Content/Scripts/pages/program-search.ts
ERROR in ./node_modules/instantsearch.js/es/widgets/menu-select/menu-select.js
Module not found: Error: Can't resolve 'react' in 'C:\Users\mattucci\Documents\Visual-Studio-2017\Projects\Ontariocolleges\Ontariocolleges\node_modules\instantsearch.js\es\widgets\menu-select'
@ ./node_modules/instantsearch.js/es/widgets/menu-select/menu-select.js 1:0-26
@ ./node_modules/instantsearch.js/es/widgets/index.js
@ ./Content/Scripts/search/search-programs-instantsearch.ts
@ ./Content/Scripts/pages/program-search.ts
ERROR in ./node_modules/instantsearch.js/es/widgets/menu-select/menu-select.js
Module not found: Error: Can't resolve 'react-dom' in 'C:\Users\mattucci\Documents\Visual-Studio-2017\Projects\Ontariocolleges\Ontariocolleges\node_modules\instantsearch.js\es\widgets\menu-select'
@ ./node_modules/instantsearch.js/es/widgets/menu-select/menu-select.js 2:0-33
@ ./node_modules/instantsearch.js/es/widgets/index.js
@ ./Content/Scripts/search/search-programs-instantsearch.ts
@ ./Content/Scripts/pages/program-search.ts
What am I doing wrong in including the widget modules and why is it asking for react as a dependency? 😦
Issue Analytics
- State:
- Created 6 years ago
- Comments:13 (8 by maintainers)
Top Results From Across the Web
Typescript Module not found Can't resolve
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 >How to fix 'Module not found: Can't resolve 'http' in ... - YouTube
Basically, just change ' react -scripts' to 4.0. 2 in your package.json and run `npm install` again :D Follow me on...
Read more >React with Typescript and Webpack
In this guide, we will look at creating React app using Webpack and using TypeScript. The upside of this is greater control over...
Read more >Resolve
Resolve. These options change how modules are resolved. Webpack provides reasonable defaults, but it is possible to change the resolving in detail.
Read more >You may need an appropriate loader to handle this file type ...
config.ts file. One quick test would be to replace the small amount of typescript in your config file with webpack.config.js and see if ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@Haroenv @bobylito So I added the alias in webpack and now everything is working fine 👍
@bobylito I never had the issue with 2.0.2, and it is only
those two widgetsthe one widgetMenuSelect
that the error comes up for, which I am not using by the way. (update)Oh and @Haroenv, sorry I can’t put up my code, I’m working with a private repo.
This should have been fixed since #2618. All references now point to
preact-compat
orpreact
in the code. Thanks for reminding us of this issue @Giovanni-Mattucci