CODEX

Duplicate Copy of React Errors When Using NPM Link

Brian Jenney
CodeX
2 min readFeb 22, 2021

--

Pic credit: https://www.seobility.net/en/wiki/On-Page_SEO.

Our team has been hard at work developing shared component and shared state libraries for our growing number of e-commerce sites. To centralize this shared logic we’ve published these libraries as npm packages. This was only half the game we soon found out.

In order for our team to use these packages in development we relied on npm-linking the local repos to our consuming front-end. npm link allows you to create a symlink from a package in your node modules to a local directory on your machine. You can read more about it here. This is a better alternative to constantly publishing a package, installing it to check out your changes and crossing your fingers… though we went down this route for longer than I’d like to admit 😅

Our UI library in particular was difficult to npm link. This package relies on React, as do the front ends that install it, leading to an error you’re probably intimately familiar with if you are reading this

Our library correctly excludes peer dependencies such as React and works fine in production but when we inspected the node_modules when npm-linking our package, we saw React was…

--

--

Brian Jenney
CodeX

full-stackish developer, late bloomer coder and power google user and owner of Parsity.io