Yarn run build: Rollup failed to resolve import

Hello, I’m taking my first steps in Netlify. Trying to deploy an Astro/React app. I got an error during deploy, at yarn run build execution.

yarn run build works properly at local, but fails in Netlify.

The error happens when trying to import @nanostores/react

Import {usestore} from '@nanostores/react';

Error:

11:16:54 AM: 10:16:54 [ERROR] [vite] [vite]: Rollup failed to resolve import "@nanostores/react" from "/opt/build/repo/src/components/Fiber.jsx".
11:16:54 AM: This is most likely unintended because it can break your application at runtime.
11:16:54 AM: If you do want to externalize this module explicitly add it to
11:16:54 AM: `build.rollupOptions.external`

Any help appreciated. Thanks.

@aitor Is @nanostores/react in your package.json?

You could attempt to replicate the issue locally by removing your dependencies (delete your node_modules folder) then install them again and run your yarn run build command.

1 Like

That was the problem, thank you very much. I can’t explain how the application could work locally without that dependency in the package.json and why it was not present. But really that’s what was happening.

Hiya @aitor glad you found your solution!

1 Like