1

I want to fork React Data Grid repo on Github, make some changes and install it in my react app.

I have added name, version, and description attributes in repo's package.json

I have tried to install it via npm install username/repo_url#branch

It does install and build the package but is ignoring the dist and lib folder in node_modules/react-data-grid/packages/*/ and I am unable to import it in my code.

I have tried

1) commenting dist in my app's .gitignore

2) adding files attribute with dist in my app's package.json

Nothing works. What am I doing wrong?

EDIT

Here is the stack trace after following @Derek Nguyen response

npm install piby180/react-data-grid#piby-current

> react-data-grid@1.0.0 postinstall C:\Users\Leo\Documents\Work\demos\myapp\node_modules\react-data-grid
> lerna bootstrap --no-ci && lerna run build

lerna notice cli v3.15.0
lerna info Bootstrapping 2 packages
lerna info Installing external dependencies
lerna info Symlinking packages and binaries
lerna success Bootstrapped 2 packages
lerna notice cli v3.15.0
lerna info Executing command in 2 packages: "npm run build"
lerna ERR! npm run build exited 1 in 'react-data-grid'
lerna ERR! npm run build stdout:

> react-data-grid@7.0.0-alpha.13 build C:\Users\Leo\Documents\Work\demos\myapp\node_modules\react-data-grid\packages\react-data-grid
> tsc

error TS6053: File 'C:/Users/Leo/Documents/Work/demos/myapp/node_modules/react-data-grid/packages/react-data-grid-addons/src/index.ts' not found.

error TS6053: File 'C:/Users/Leo/Documents/Work/demos/myapp/node_modules/react-data-grid/packages/react-data-grid/src/index.ts' not found.


Found 2 errors.


lerna ERR! npm run build stderr:
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-data-grid@7.0.0-alpha.13 build: `tsc`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-data-grid@7.0.0-alpha.13 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Leo\AppData\Roaming\npm-cache\_logs\2019-07-17T14_35_42_219Z-debug.log

lerna ERR! npm run build exited 1 in 'react-data-grid'
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\jest-haste-map\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-data-grid@1.0.0 postinstall: `lerna bootstrap --no-ci && lerna run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-data-grid@1.0.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!    
piby180
  • 388
  • 1
  • 6
  • 18
  • What do you mean ignoring and can you kindly explain what error is thrown when you try to import it? – aaKhan Jul 12 '19 at 08:41
  • When I install the official package, there is a dist folder containing react-data-grid.js and react-data-grid.min.js. There is no such dist folder when I install from my forked repo. I am assuming npm build the repo and ignore the dist folder somehow. When I try to import it, it just says "Cannot import react-data-grid ..." – piby180 Jul 12 '19 at 08:47
  • Please share the url of your forked repo and the branch you're trying to install. Let me try it on my pc. – aaKhan Jul 12 '19 at 08:49
  • https://github.com/piby180/react-data-grid/tree/piby-current – piby180 Jul 12 '19 at 08:55

1 Answers1

0

The 'postinstall' script in the package runs lerna bootstrap. According to the doc, it will then do the following:

When run, this command will:

  • npm install all external dependencies of each package.

  • Symlink together all Lerna packages that are dependencies of each other.

  • npm run prepublish in all bootstrapped packages (unless --ignore-prepublish is passed).

  • npm run prepare in all bootstrapped packages.

The packages in /packages don't have a prepare or prepublish script. You should be able to properly build the subpackage by modifying the root package.json's postinstall script:

postinstall": "lerna bootstrap --no-ci && lerna run build",

I think that should properly build the sub packages.

Community
  • 1
  • 1
Derek Nguyen
  • 11,294
  • 1
  • 40
  • 64
  • Thank you for your answer. That is some progress but I am still not able to install it. Lerna successfully bootstrapped two packages but then I got error from tsc 'File node_modules/react-data-grid/src/index.ts' not found ; 'File node_modules/react-data-grid-addons/src/index.ts' not found – piby180 Jul 16 '19 at 15:49
  • hhhm, I've just tried to install your fork via `yarn add https://github.com/piby180/react-data-grid#piby-current` & met with a bunch of tsc compiling error -- meaning tsc can see the index files. Can you edit question to add more detail of your new error? – Derek Nguyen Jul 17 '19 at 05:25
  • @piby180 the project you installing this package in, is it _also_ in a typescript environment? That might not matter though, as tsc should be invoked from the closest node_modules... hhhm – Derek Nguyen Jul 19 '19 at 02:03