Create-react-app: imports do not find packages linked via 'yarn link'

Created on 1 Feb 2018  ·  5Comments  ·  Source: facebook/create-react-app

Is this a bug report?

Yes

Did you try recovering your dependencies?

Yes
1.3.2

Which terms did you search for in User Guide?

failed to compile for yarn linked packages
cannot resolve local packages
module not found when importing npm linked pacakges

Environment

yarn --version
1.3.2
node -v
v8.9.1
npm -v
5.5.1
yarn --version
1.3.2
npm ls react-scripts
└── [email protected]

Then, specify:

  1. Operating system: OSX 10.13.1
  2. Browser and version (if relevant): FF, Chrome, Safari

Steps to Reproduce

(Write your steps here:)

  1. Clone a module (i.e. https://github.com/jakezatecky/react-checkbox-tree )
  2. cd into that directory
  3. yarn link
  4. cd into main project
  5. yarn link 'react-checkbox-tree'
  6. Add import CheckboxTree from 'react-checkbox-tree'; to a component
  7. Run

Expected Behavior

It should resolve the module.

Actual Behavior

I see the module is symlinked within node_modules, but the app is looking only relative to the component:

Failed to Compile
Module not found: Can't resolve 'react-checkbox-tree' in '/Users/un/gd/client/src/modules/categories/components'

Reproducible Demo

Most helpful comment

It is failing because the main entry of react-checkbox-tree points to lib/index.js. But that file doesn't exist if you just clone a repository.

If you run yarn build in react-checkbox-tree, that will create the lib folder. If you manage to get it building (I had to remove linters from the gulpfile because they failed for me), linking will work.

All 5 comments

It is failing because the main entry of react-checkbox-tree points to lib/index.js. But that file doesn't exist if you just clone a repository.

If you run yarn build in react-checkbox-tree, that will create the lib folder. If you manage to get it building (I had to remove linters from the gulpfile because they failed for me), linking will work.

@gaearon Got it, thanks!!!

@gaearon when I'm running yarn build in the package's folder, yarn returns error Command "build" not found.

Oh ... thank you @bugzpodder

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fson picture fson  ·  3Comments

alleroux picture alleroux  ·  3Comments

JimmyLv picture JimmyLv  ·  3Comments

DaveLindberg picture DaveLindberg  ·  3Comments

Evan-GK picture Evan-GK  ·  3Comments