【问题标题】:How do I get my react project running after cloning it from github as I receive errors after running npm install command当我在运行 npm install 命令后收到错误时,如何从 github 克隆我的 react 项目后运行
【发布时间】:2021-12-08 18:03:09
【问题描述】:

所以我首先运行 git clone http://........... 并成功下载项目

然后我运行 cd 来更改目录。这行得通!

我在目录下运行npm install,cmd行显示如下错误

npm ERR! code EJSONPARSE
npm ERR! path C:\Users\Home\Documents\Ctr-Alt-Elite/package.json
npm ERR! JSON.parse Unexpected token "<" (0x3C) in JSON at position 625 while parsing near "...us-bar\": \"~1.1.0\",\r\n<<<<<<< HEAD\r\n    \"f..."
npm ERR! JSON.parse Failed to parse JSON data.
npm ERR! JSON.parse Note: package.json must be actual JSON, not just JavaScript.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Home\AppData\Local\npm-cache\_logs\2021-12-08T17_53_50_035Z-debug.log

下面是debug.log文件

0 verbose cli [
0 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
0 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli   'start'
0 verbose cli ]
1 info using npm@8.1.2
2 info using node@v16.13.1
3 timing npm:load:whichnode Completed in 3ms
4 timing config:load:defaults Completed in 9ms
5 timing config:load:file:C:\Program Files\nodejs\node_modules\npm\npmrc Completed in 4ms
6 timing config:load:builtin Completed in 4ms
7 timing config:load:cli Completed in 2ms
8 timing config:load:env Completed in 1ms
9 timing config:load:file:C:\Users\Home\Documents\Ctr-Alt-Elite\.npmrc Completed in 0ms
10 timing config:load:project Completed in 1ms
11 timing config:load:file:C:\Users\Home\.npmrc Completed in 1ms
12 timing config:load:user Completed in 1ms
13 timing config:load:file:C:\Users\Home\AppData\Roaming\npm\etc\npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:credentials Completed in 2ms
17 timing config:load:setEnvs Completed in 1ms
18 timing config:load Completed in 21ms
19 timing npm:load:configload Completed in 22ms
20 timing npm:load:setTitle Completed in 1ms
21 timing npm:load:setupLog Completed in 1ms
22 timing config:load:flatten Completed in 4ms
23 timing npm:load:cleanupLog Completed in 6ms
24 timing npm:load:configScope Completed in 0ms
25 timing npm:load:projectScope Completed in 7ms
26 timing npm:load Completed in 52ms
27 timing command:run-script Completed in 8ms
28 timing command:start Completed in 26ms
29 verbose stack JSONParseError: Unexpected token "<" (0x3C) in JSON at position 625 while parsing near "...us-bar\": \"~1.1.0\",\r\n<<<<<<< HEAD\r\n    \"f..."
29 verbose stack     at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json-fast\index.js:11:61
29 verbose stack     at async RunScript.run (C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:87:19)
30 verbose cwd C:\Users\Home\Documents\Ctr-Alt-Elite
31 verbose Windows_NT 10.0.19043
32 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
33 verbose node v16.13.1
34 verbose npm  v8.1.2
35 error code EJSONPARSE
36 error path C:\Users\Home\Documents\Ctr-Alt-Elite/package.json
37 error JSON.parse Unexpected token "<" (0x3C) in JSON at position 625 while parsing near "...us-bar\": \"~1.1.0\",\r\n<<<<<<< HEAD\r\n    \"f..."
38 error JSON.parse Failed to parse JSON data.
38 error JSON.parse Note: package.json must be actual JSON, not just JavaScript.
39 verbose exit 1

【问题讨论】:

  • 项目有安装说明吗?
  • 没有。几天前,我能够简单地从 gitlab 下载压缩的项目文件夹并将其解压缩到正确的目录,然后它就可以工作了。我可以 npm install 然后 npm start 并且该项目可以工作。从那时起,新文件已提交,并且 git clone/npm 安装选项(此选项在此项目中从未对我有用)和下载压缩文件夹/npm(仅在几天前工作)安装选项现在都不适用于我。
  • 请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。

标签: node.js reactjs npm-install


【解决方案1】:

看起来有人在 package.json 中提交了合并冲突,导致 JSON 无效。要解决此问题,请转到 package.json 并解决冲突。 Here 是一篇解释手动合并所需的所有内容的文章。它的要点是冲突看起来像这样:

<<<<<<< HEAD
// Here is the code for your version/branch
=======
// Here is the version from the version/branch you're merging in
>>>>>>> <branch-/tagname or commitref>

然后你需要手动决定应该从两个版本中保留什么,当然,删除标记。

【讨论】:

  • 在提交错误后运行 git mergetool 将无济于事。在任何情况下,这都不是 Git 问题——问题在于提供软件的人并没有实际测试他们提供的内容。
  • 啊。没有考虑到这一点。我会更新我的答案。谢谢指出
猜你喜欢
  • 2023-03-21
  • 1970-01-01
  • 2013-08-22
  • 2021-11-16
  • 2020-12-08
  • 2018-07-21
  • 2021-03-01
  • 1970-01-01
  • 2021-02-26
相关资源
最近更新 更多