Cannot import replaceComponent from "@reactioncommerce/reaction-commerce"


#1

Hello, I’m trying to replace the default navbar with a custom navbar.

I have a container for this in my plugin created via the cli:

import { replaceComponent } from “@reactioncommerce/reaction-components”;
import MarsNavBar from ‘…/components/navbar’;
replaceComponent(“NavBar”, MarsNavBar);

I’m getting an error which says that the module @reactioncommerce/reaction-components cannot be resolved. I’m using reaction commerce 1.11.0.

Help would be greatly appreciated!
Best regards.


#2

I assume your plugin has a package.json. It is most likely overriding the root-level package.json, which contains the Babel alias for @reactioncommerce/reaction-components. You can either remove the plugin’s package.json if it doesn’t have any local dependencies, or copy the alias.

These are quick fixes so any better solution would be greatly appreciated.