`npm link` to Project using Styled Components Causes Errors

Hey,

I am new to Meteor but fairly experienced with React and I recently joined a project which uses Meteor on the back and React up front.

We have an internal component library which uses Styled Components and I would like to link locally to the project to speed up development via npm link but I receive errors about multiple copies of styled-components.

There is a solution on the Styled Components site which explains how to configure Webpack: styled-components: FAQs

Does Meteor use Webpack (it doesn’t seem to)?

What can I do to make this work in Meteor?

Andy

Hey @atwright147, npm link should work fine. We have documented here how to use it.

Have you checked if you have more than one version of that package in our node_modules?

Perhaps you have now referenced both the remote and the local package?

1 Like

I’ll continue looking into this on Monday but there will be one instance of Styled Components in the Meteor project and one in the Shared Components (SC) lib. Presumably that means that there are two instances of the lib present.

I cannot remove SC from the lib as that will break it in Storybook and I cannot remove it from Meteor because that would break that project.

It makes sense that I should need to control which instance is used but is that possible in the Meteor build? How is the Meteor build handled under the hood?