v6.0.0 - Module not found: Can't resolve 'p-memoize' in create-react-app
See original GitHub issueI was previously using p-memoize
v5.0.1 successfully in a create-react-app project. When I try upgrading to the new p-memoize
v6.0.0 I get errors like:
Failed to compile.
./src/index.tsx
Module not found: Can't resolve 'p-memoize' in 'C:\Users\user\folder\my-app\src'
Steps to reproduce:
- Create a new template TypeScript CRA project:
npx create-react-app my-app --template typescript
- Install
p-memoize
as a dependency in the project:
npm i p-memoize
- Try importing
p-memoize
in e.g.index.tsx
:
...
import reportWebVitals from "./reportWebVitals";
import "p-memoize";
ReactDOM.render(
...
- Try starting the app:
npm start
This results in an error message as above. It works if you downgrade p-memoize
to v5.0.1.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Create-react-app : Module not found: Error: Can't resolve
Using Create-react-app with VS2022 (typescript). what I tried : Tried the Javascript and Typescript version; delete the package-lock.json ...
Read more >Releases - styled-components
Fix React Native components accepts function as style prop. (see #3389) ... Fixes the "stream" module not getting properly DCE'd for browser build...
Read more >react-scripts - npm
Configuration and scripts for Create React App.. Latest version: 5.0.1, ... There are no other projects in the npm registry using react-scripts.
Read more >mars/create-react-app-buildpack - Heroku Elements
create -react-app-buildpack - Buildpack for Heroku. ... Any server request that would result in 404 Not Found returns the React app.
Read more >You need to update your react-script package. As craco@6.4 ...
Module not found : Error: Can't resolve 'stream' in '/Users/pedrolima/Desktop/React_Projects/app/node_modules/@react-pdf/pdfkit/lib'.
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 Free
Top 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
FYI, the latest version of p-memoize (6.0.1) now works with the newly released version of create-react-app (5.0.0).
FYI @sindresorhus I just had a bit more of a look at this.
The problem is caused by a change in
package.json
fromto
i.e. adding a subpath to exports breaks it. I tested hacking the package to remove the subpath and it works again.
I went looking for potentially associated outstanding issues against create-react-app and found the following:
https://github.com/facebook/create-react-app/issues/10933 https://github.com/facebook/create-react-app/issues/10892 https://github.com/facebook/create-react-app/issues/11528
So it seems there are known issues with create-react-app around this.