【发布时间】:2021-11-04 23:44:21
【问题描述】:
所以我有一个分叉项目,我试图在我的 React 代码中引用。我注意到该软件包的 d3 版本与我自己的不同(它使用 5.5.0,我的使用 6.6.2)。每当我尝试做npm install d3@5.5.0
我收到了这些错误
npm ERR! code 128
npm ERR! An unknown git error occurred
npm ERR! command git --no-replace-objects ls-remote ssh://git@github.com/<username>/react-d3-graph.git
npm ERR! git@github.com: Permission denied (publickey).
npm ERR! fatal: Could not read from remote repository.
npm ERR!
npm ERR! Please make sure you have the correct access rights
npm ERR! and the repository exists.
我创建了一个 .env 文件。我知道了
SKIP_PREFLIGHT_CHECK=true
REACT_APP_React=SHA256:/<code>
我已经删除了 node_modules 和 package-lock.json。 我确认代码与我在 GitHub 上的 SSH、标题和所有内容相同。我不太确定为什么会这样。
这是我的 package.json
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^11.1.0",
"@testing-library/user-event": "^12.1.10",
"csvtojson": "^2.0.10",
"d3": "^6.6.2",
"d3-selection": "^2.0.0",
"papaparse": "^5.3.0",
"react": "^17.0.1",
"react-data-table-component": "^7.0.0-alpha-5",
"react-dom": "^17.0.1",
"react-file-reader": "^1.1.4",
"react-request": "^3.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "^4.0.2",
"react-scroll-wheel-handler": "^2.0.1",
"styled-components": "^5.2.1",
"use-neo4j": "^0.3.5",
"web-vitals": "^1.0.1",
"write-json-file": "^4.3.0",
"xlsx": "^0.16.9",
"xtypejs": "^0.7.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"api": "npx json-server --watch .\\src\\components\\limit.json --port 8000"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"axios": "^0.21.1",
"d3-drag": "^2.0.0",
"d3-force": "^2.1.1",
"d3-zoom": "^2.0.0",
"react-d3-graph": "<git_username>/react-d3-graph",
"react-router-scroll": "^0.4.4",
"react-use": "^17.2.4"
}
}
【问题讨论】:
-
你是问如何运行它还是如何将它包含在一个单独的项目中?
-
我将如何实现它以便我仍然可以调用函数,以及我实现和导出的函数。因此,例如,如果我将函数更改为执行 a+b 而不是 b+c,它将调用我的函数执行 a+b。但是如何将它也包含在当前项目中
-
该项目上的代码文件在
export他们的组件中看起来就像任何其他 JavaScript 应用程序一样。你能把你的分叉版本放在你项目的一个文件夹中,然后import你需要什么吗?或者您是否一定需要单独构建此项目并将其构建输出包含在您的项目中的node_modules中?