Cannot find module "react-select/animated" while running strapi build

System Information
  • Strapi Version: 4.4.3 / 4.4.5
  • Operating System: Windows&Linux
  • Database: SQL on dev and postgres on production
  • Node Version: 16.17.1
  • NPM Version: 8.15.0
  • Yarn Version: X

I upgraded the project to typescript and followed the exact steps from the docs.
It was all working fine until i wanted to deploy it to my Linux server.

This error showed basically 5 seconds into building:

"C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" run build --scripts-prepend-node-path=auto

> xxxcms@0.1.0 build
> strapi build

This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: Cannot find module 'react-select/animated'
Require stack:
- C:\xxxcms\node_modules\@strapi\admin\webpack.alias.js
- C:\xxxcms\node_modules\@strapi\admin\webpack.config.js
- C:\xxxcms\node_modules\@strapi\admin\utils\get-custom-webpack-config.js
- C:\xxxcms\node_modules\@strapi\admin\utils\index.js
- C:\xxxcms\node_modules\@strapi\admin\index.js
- C:\xxxcms\node_modules\@strapi\strapi\lib\commands\builders\admin.js
- C:\xxxcms\node_modules\@strapi\strapi\lib\commands\builders\index.js
- C:\xxxcms\node_modules\@strapi\strapi\lib\commands\build.js
- C:\xxxcms\node_modules\@strapi\strapi\bin\strapi.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)
    at Function.resolve (node:internal/modules/cjs/helpers:108:19)
    at C:\xxxcms\node_modules\@strapi\admin\webpack.alias.js:51:25
    at Array.reduce (<anonymous>)
    at Object.<anonymous> (C:\xxxcms\node_modules\@strapi\admin\webpack.alias.js:50:12)
    at Module._compile (node:internal/modules/cjs/loader:1126:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Module.require (node:internal/modules/cjs/loader:1028:19)

Process finished with exit code 0

After that i was curious why it doesnt work on a freshly cleaned environment.
So locally in my project, i deleted the dist, build and node-modules.
If have no custom webpack.config.js and the tsconfig files are exactly like those from the Docs

And there you go, got the same error now locally.

So i tried to install the missing library manually, but:
npm install react-select/animated throws an error that this repository is private
npm install react-select-animated installs a repo, but it doesnt change the error

I really have no clue what to do, haaalp ._.

4 Likes

Hi,
did you solved this issues?
I have now the same issue with node 16.
Do you have any ideas?

Many thanks and best regards,
Andre

I have the same issue on a build box. I’m going to try cleaning nm folder and see if it occurs locally.

It doesn’t occur locally for me on windows 10 pro 64. But if I run it on an azure build with linux it gives the above error.

I did a full delete of NM folder, yarn.lock, .cache and build folders. Installed 4.4.5 Strapi and rebuilt. All builds and runs fine locally. No errors.

I’m getting the same error as Cascace above on the Linux build, though. Would appreciate some advice on how to proceed.

1 Like

I ran into this problem as well when I was running locally in the middle of migrating from v3 to v4. At first, I got the error about missing react-select/animated. Just to see if it would work, I installed react-select as a dependency and things worked until I hit the same error twice but for different packages. First was style-loader and the second was css-loader. Once I added all those packages in, things worked fine. :woman_shrugging:t5:

Just as an experiment, I deleted all the .cache, build, and node_modules folders as well as the package-lock.json file and rebuilt everything. That time things worked straight away without having to do any other installs. So it seems like certain packages aren’t installing correctly.

4 Likes

Thanks, I’ve already tried a complete re-install, but that was how I got this error in the first place (it included a minor patch bump from 4.4.3 to 4.4.5). It doesn’t fail locally, only on the linux build box (which gets all deps new every time).

This feels like a strapi dep-chain issue rather than a local one.

1 Like

Strapi Cloud Beta also does not seem to like this, though the logs are kinda vague on the issue.

i do have the same problem anyone find a solution in heroku hosting wtf is react-select/animated


> my-project-1@0.1.0 build
> strapi build

This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). The promise rejected with the reason:
Error: Cannot find module 'react-select/animated'
Require stack:
- /app/node_modules/@strapi/admin/webpack.alias.js
- /app/node_modules/@strapi/admin/webpack.config.js
- /app/node_modules/@strapi/admin/utils/get-custom-webpack-config.js
- /app/node_modules/@strapi/admin/utils/index.js
- /app/node_modules/@strapi/admin/index.js
- /app/node_modules/@strapi/strapi/lib/commands/builders/admin.js
- /app/node_modules/@strapi/strapi/lib/commands/builders/index.js
- /app/node_modules/@strapi/strapi/lib/commands/build.js
- /app/node_modules/@strapi/strapi/bin/strapi.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.resolve (internal/modules/cjs/helpers.js:107:19)
    at /app/node_modules/@strapi/admin/webpack.alias.js:51:25
    at Array.reduce (<anonymous>)
    at Object.<anonymous> (/app/node_modules/@strapi/admin/webpack.alias.js:50:12)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)

Thanks, I also had to install all of these to get it to work.

I migrated from v3 to v4 a few days ago and had no issue at first, the problem appeared only after I tried t add more dependencies to the project.

1 Like

Also getting the same with a new custom typescript project.

Thanks @forever_monee this helped.

1 Like

For us, it was a case of downgrading node from 16 to 14.

FYI I updated to the latest Strapi version and the problem seems to have disappeared

1 Like

Good shout. I had to remove my node-modules folder and reinstall to get it to build, but that’s fixed. Thanks.

I also want to upgrade v3 to v4, so do I need to go through strapiv3 to v4 migration progress.
please help me to figure it out

I would recommend following the youtube videos: Strapi v3 to v4 Migration Overview [ Strapi Migration Guide Part 1 ] - YouTube

Hopefully it goes smoothly for you… It’s not that easy

This has occurred to me as well when migrating to strapi v4.6.1, the solution was to install react-select.

1 Like