Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing npm package from fork with yarn + webpack - Can't resolve './dist/

I want to contribute to an open source React Component and I'd like to use a fork of the project in my webpack bundle.

I am using yarn and I tried to install my fork using

yarn add github:Startouf/react-coverflow

However, when webpack tries to compile my bundle, it raises weird errors

ERROR in ./~/react-coverflow/main.js
Module not found: Error: Can't resolve './dist/react-coverflow' in '/Users/Cyril/dev/MyApp/client/node_modules/react-coverflow'

Did I miss something ?

EDIT : when I use the released package from npm, the node module folder contains

LICENSE     README.md   dist        main.js     package.json

When I use my fork, it seems like the project isn't compiled and contains

LICENSE         README.md       package.json        src         webpack.config.js
Makefile        main.js         site            test

Seems like I'm missing a step... I though doing yarn add with a github fork would automatically make a release but seems like I'm wrong ?

like image 321
Cyril Duchon-Doris Avatar asked Apr 14 '17 09:04

Cyril Duchon-Doris


1 Answers

Unfortunately, using a repository directly as source can result in execution error. This is because it's not bundled at all, while the package expects an prebuilt version existing in dist. The bundling scripts are often executed before publishing releases to npm.

Some workarounds are:

  • execute the prepublish step in the target directory (this depends on what the project uses)
  • of course, using the published version is the best. create your own package on npm and upload it.

References: npm issue

like image 147
Tatsuyuki Ishi Avatar answered Nov 12 '22 17:11

Tatsuyuki Ishi