1
votes

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

> [email protected] 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:

> [email protected] 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! [email protected] build: `tsc`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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: [email protected] (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\jest-haste-map\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `lerna bootstrap --no-ci && lerna run build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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!    
1
What do you mean ignoring and can you kindly explain what error is thrown when you try to import it? - aaKhan
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
Please share the url of your forked repo and the branch you're trying to install. Let me try it on my pc. - aaKhan

1 Answers

0
votes

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.