【发布时间】:2019-11-21 23:26:55
【问题描述】:
我想在 Github 上 fork React Data Grid repo,进行一些更改并将其安装到我的 react 应用程序中。
我在 repo 的 package.json 中添加了名称、版本和描述属性
我尝试通过以下方式安装它 npm 安装用户名/repo_url#branch
它确实安装并构建了包,但忽略了 node_modules/react-data-grid/packages/*/ 中的 dist 和 lib 文件夹,我无法在我的代码中导入它。
我试过了
1) 在我的应用程序的 .gitignore 中评论 dist
2) 在我的应用程序的 package.json 中添加带有 dist 的 files 属性
没有任何作用。 我做错了什么?
编辑
这是遵循@Derek Nguyen 响应后的堆栈跟踪
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!
【问题讨论】:
-
忽略是什么意思,您能否解释一下尝试导入时抛出的错误?
-
我安装官方包的时候,有一个dist文件夹,里面有react-data-grid.js和react-data-grid.min.js。当我从分叉的 repo 安装时,没有这样的 dist 文件夹。我假设 npm 构建 repo 并以某种方式忽略 dist 文件夹。当我尝试导入它时,它只是说“无法导入 react-data-grid ...”
-
请分享您的分叉仓库的 url 和您尝试安装的分支。让我在我的电脑上试试。
标签: reactjs npm npm-scripts react-data-grid