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.

v6.0.0 - Module not found: Can't resolve 'p-memoize' in create-react-app

See original GitHub issue

I 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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
cduffcommented, Dec 15, 2021

FYI, the latest version of p-memoize (6.0.1) now works with the newly released version of create-react-app (5.0.0).

1reaction
cduffcommented, Oct 20, 2021

FYI @sindresorhus I just had a bit more of a look at this.

The problem is caused by a change in package.json from

"exports": "./index.js",

to

"exports": "./dist/index.js",

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.

Read more comments on GitHub >

github_iconTop 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 >

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