【问题标题】:Issue in configuring eslint to express project配置 eslint 来表达项目的问题
【发布时间】:2018-12-24 18:43:30
【问题描述】:

我一直在参考 https://www.npmjs.com/package/eslint 为我的 express 项目配置 eslint,当我安装 eslint 包时,我收到如下错误

npm 错误!在 '.../ajv-1.4.2.tgz"}},"1.' 附近解析时 JSON 输入意外结束

npm 错误!可以在以下位置找到此运行的完整日志:npm ERR!
C:\Users\Ramitha\AppData\Roaming\npm-cache_logs\2018-07-17T06_22_50_551Z-debug.log

package.json

{
  "name": "name",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "nodemon index.js"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.18.3",
    "express": "^4.16.3",
    "nodemon": "^1.18.2"
  }
}

2018-07-17T06_22_50_551Z-debug.log

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   'eslint',
1 verbose cli   '-g' ]
2 info using npm@5.6.0
3 info using node@v8.11.3
4 verbose npm-session 54a68bf0918c64f2
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 200 https://registry.npmjs.org/eslint 42ms (from cache)
8 silly pacote tag manifest for eslint@latest fetched in 123ms
9 silly install loadIdealTree
10 silly install cloneCurrentTreeToIdealTree
11 silly install loadShrinkwrap
12 silly install loadAllDepsIntoIdealTree
13 silly resolveWithNewModule eslint@5.1.0 checking installable status
14 http fetch GET 200 https://registry.npmjs.org/ajv 185ms (from cache)
15 http fetch GET 200 https://registry.npmjs.org/babel-code-frame 180ms (from cache)
16 http fetch GET 200 https://registry.npmjs.org/debug 179ms (from cache)
17 http fetch GET 200 https://registry.npmjs.org/eslint-scope 178ms (from cache)
18 http fetch GET 200 https://registry.npmjs.org/doctrine 179ms (from cache)
19 http fetch GET 200 https://registry.npmjs.org/cross-spawn 181ms (from cache)
20 silly fetchPackageMetaData error for ajv@^6.5.0 Unexpected end of JSON input while parsing near '.../ajv-1.4.2.tgz"}},"1.'
21 http fetch GET 200 https://registry.npmjs.org/eslint-utils 194ms (from cache)
22 silly pacote range manifest for debug@^3.1.0 fetched in 198ms
23 silly resolveWithNewModule debug@3.1.0 checking installable status
24 silly pacote range manifest for babel-code-frame@^6.26.0 fetched in 207ms
25 silly resolveWithNewModule babel-code-frame@6.26.0 checking installable status
26 silly pacote range manifest for eslint-scope@^4.0.0 fetched in 200ms
27 silly resolveWithNewModule eslint-scope@4.0.0 checking installable status
28 silly pacote range manifest for doctrine@^2.1.0 fetched in 201ms
29 silly resolveWithNewModule doctrine@2.1.0 checking installable status
30 silly pacote range manifest for cross-spawn@^6.0.5 fetched in 205ms
31 silly resolveWithNewModule cross-spawn@6.0.5 checking installable status
32 http fetch GET 200 https://registry.npmjs.org/eslint-visitor-keys 254ms (from cache)
33 http fetch GET 200 https://registry.npmjs.org/espree 254ms (from cache)
34 silly pacote range manifest for eslint-utils@^1.3.1 fetched in 259ms
35 silly resolveWithNewModule eslint-utils@1.3.1 checking installable status
36 silly pacote range manifest for eslint-visitor-keys@^1.0.0 fetched in 320ms
37 silly resolveWithNewModule eslint-visitor-keys@1.0.0 checking installable status
38 silly pacote range manifest for espree@^4.0.0 fetched in 323ms
39 silly resolveWithNewModule espree@4.0.0 checking installable status
40 http fetch GET 200 https://registry.npmjs.org/esquery 236ms (from cache)
41 http fetch GET 200 https://registry.npmjs.org/file-entry-cache 223ms (from cache)
42 http fetch GET 200 https://registry.npmjs.org/glob 222ms (from cache)
43 http fetch GET 200 https://registry.npmjs.org/functional-red-black-tree 223ms (from cache)
44 http fetch GET 200 https://registry.npmjs.org/esutils 228ms (from cache)
45 http fetch GET 200 https://registry.npmjs.org/globals 228ms (from cache)
46 silly pacote range manifest for esquery@^1.0.1 fetched in 248ms
47 silly resolveWithNewModule esquery@1.0.1 checking installable status
48 http fetch GET 200 https://registry.npmjs.org/ignore 172ms (from cache)
49 silly pacote range manifest for file-entry-cache@^2.0.0 fetched in 236ms
50 silly resolveWithNewModule file-entry-cache@2.0.0 checking installable status
51 silly pacote range manifest for functional-red-black-tree@^1.0.1 fetched in 237ms
52 silly resolveWithNewModule functional-red-black-tree@1.0.1 checking installable status
53 silly pacote range manifest for glob@^7.1.2 fetched in 238ms
54 silly resolveWithNewModule glob@7.1.2 checking installable status
55 silly pacote range manifest for esutils@^2.0.2 fetched in 242ms
56 silly resolveWithNewModule esutils@2.0.2 checking installable status
57 silly pacote range manifest for globals@^11.7.0 fetched in 242ms
58 silly resolveWithNewModule globals@11.7.0 checking installable status
59 http fetch GET 200 https://registry.npmjs.org/inquirer 117ms (from cache)
60 silly fetchPackageMetaData error for inquirer@^5.2.0 Unexpected end of JSON input while parsing near '...":"^2.1.0","gulp-plum'
61 silly pacote range manifest for ignore@^3.3.3 fetched in 189ms
62 silly resolveWithNewModule ignore@3.3.10 checking installable status
63 http fetch GET 200 https://registry.npmjs.org/is-resolvable 31ms (from cache)
64 http fetch GET 200 https://registry.npmjs.org/js-yaml 30ms (from cache)
65 http fetch GET 200 https://registry.npmjs.org/json-stable-stringify-without-jsonify 29ms (from cache)
66 http fetch GET 200 https://registry.npmjs.org/lodash 27ms (from cache)
67 http fetch GET 200 https://registry.npmjs.org/levn 29ms (from cache)
68 http fetch GET 200 https://registry.npmjs.org/mkdirp 24ms (from cache)
69 silly pacote range manifest for is-resolvable@^1.1.0 fetched in 40ms
70 silly resolveWithNewModule is-resolvable@1.1.0 checking installable status
71 silly pacote range manifest for js-yaml@^3.11.0 fetched in 38ms
72 silly resolveWithNewModule js-yaml@3.12.0 checking installable status
73 http fetch GET 200 https://registry.npmjs.org/natural-compare 25ms (from cache)
74 silly pacote range manifest for json-stable-stringify-without-jsonify@^1.0.1 fetched in 35ms
75 silly resolveWithNewModule json-stable-stringify-without-jsonify@1.0.1 checking installable status
76 silly pacote range manifest for lodash@^4.17.5 fetched in 34ms
77 silly resolveWithNewModule lodash@4.17.10 checking installable status
78 silly pacote range manifest for levn@^0.3.0 fetched in 38ms
79 silly resolveWithNewModule levn@0.3.0 checking installable status
80 silly pacote range manifest for mkdirp@^0.5.1 fetched in 34ms
81 silly resolveWithNewModule mkdirp@0.5.1 checking installable status
82 silly pacote range manifest for natural-compare@^1.4.0 fetched in 36ms
83 silly resolveWithNewModule natural-compare@1.4.0 checking installable status
84 http fetch GET 200 https://registry.npmjs.org/optionator 21ms (from cache)
85 http fetch GET 200 https://registry.npmjs.org/pluralize 24ms (from cache)
86 http fetch GET 200 https://registry.npmjs.org/progress 24ms (from cache)
87 http fetch GET 200 https://registry.npmjs.org/regexpp 21ms (from cache)
88 silly pacote range manifest for optionator@^0.8.2 fetched in 29ms
89 silly resolveWithNewModule optionator@0.8.2 checking installable status
90 silly pacote range manifest for pluralize@^7.0.0 fetched in 28ms
91 silly resolveWithNewModule pluralize@7.0.0 checking installable status
92 http fetch GET 200 https://registry.npmjs.org/require-uncached 21ms (from cache)
93 silly pacote range manifest for regexpp@^1.1.0 fetched in 27ms
94 silly resolveWithNewModule regexpp@1.1.0 checking installable status
95 silly pacote range manifest for progress@^2.0.0 fetched in 32ms
96 silly resolveWithNewModule progress@2.0.0 checking installable status
97 silly pacote range manifest for require-uncached@^1.0.3 fetched in 29ms
98 silly resolveWithNewModule require-uncached@1.0.3 checking installable status
99 http fetch GET 200 https://registry.npmjs.org/string.prototype.matchall 37ms (from cache)
100 http fetch GET 200 https://registry.npmjs.org/table 39ms (from cache)
101 silly pacote range manifest for string.prototype.matchall@^2.0.0 fetched in 47ms
102 silly resolveWithNewModule string.prototype.matchall@2.0.0 checking installable status
103 silly fetchPackageMetaData error for table@^4.0.3 Unexpected end of JSON input while parsing near '...8eba","tarball":"http'
104 http fetch GET 200 https://registry.npmjs.org/text-table 48ms (from cache)
105 silly pacote range manifest for text-table@^0.2.0 fetched in 50ms
106 silly resolveWithNewModule text-table@0.2.0 checking installable status
107 http fetch GET 304 https://registry.npmjs.org/chalk 578ms (from cache)
108 silly pacote range manifest for chalk@^2.1.0 fetched in 586ms
109 silly resolveWithNewModule chalk@2.4.1 checking installable status
110 http fetch GET 304 https://registry.npmjs.org/imurmurhash 320ms (from cache)
111 http fetch GET 304 https://registry.npmjs.org/semver 160ms (from cache)
112 silly pacote range manifest for imurmurhash@^0.1.4 fetched in 325ms
113 silly resolveWithNewModule imurmurhash@0.1.4 checking installable status
114 silly pacote range manifest for semver@^5.5.0 fetched in 166ms
115 silly resolveWithNewModule semver@5.5.0 checking installable status
116 http fetch GET 304 https://registry.npmjs.org/path-is-inside 185ms (from cache)
117 silly pacote range manifest for path-is-inside@^1.0.2 fetched in 191ms
118 silly resolveWithNewModule path-is-inside@1.0.2 checking installable status
119 http fetch GET 304 https://registry.npmjs.org/strip-ansi 168ms (from cache)
120 http fetch GET 304 https://registry.npmjs.org/minimatch 229ms (from cache)
121 silly pacote range manifest for strip-ansi@^4.0.0 fetched in 174ms
122 silly resolveWithNewModule strip-ansi@4.0.0 checking installable status
123 silly pacote range manifest for minimatch@^3.0.4 fetched in 238ms
124 silly resolveWithNewModule minimatch@3.0.4 checking installable status
125 http fetch GET 304 https://registry.npmjs.org/strip-json-comments 178ms (from cache)
126 silly pacote range manifest for strip-json-comments@^2.0.1 fetched in 183ms
127 silly resolveWithNewModule strip-json-comments@2.0.1 checking installable status
128 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '.../ajv-1.4.2.tgz"}},"1.'
128 verbose stack     at JSON.parse (<anonymous>)
128 verbose stack     at parseJson (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\node_modules\json-parse-better-errors\index.js:7:17)
128 verbose stack     at consumeBody.call.then.buffer (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\src\body.js:96:50)
128 verbose stack     at <anonymous>
128 verbose stack     at process._tickCallback (internal/process/next_tick.js:188:7)
129 verbose cwd C:\Users\Ramitha\Desktop\Projects\backend
130 verbose Windows_NT 10.0.15063
131 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "eslint" "-g"
132 verbose node v8.11.3
133 verbose npm  v5.6.0
134 error Unexpected end of JSON input while parsing near '.../ajv-1.4.2.tgz"}},"1.'
135 verbose exit [ 1, true ]

我怎样才能做到这一点?请帮帮我

【问题讨论】:

  • 删除 nodemodules 然后执行 npm install 并尝试执行 npm i eslint --save 命令
  • 我已经这样做了。但还是不行
  • 你能把2018-07-17T06_22_50_551Z-debug.log的日志贴出来
  • 我通过添加 2018-07-17T06_22_50_551Z-debug.log 文件编辑了我的答案
  • 错误确实发生在这个文件 C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\node_modules\json- parse-better-errors\index.js:7:17 尝试更正该文件

标签: node.js express npm eslint


【解决方案1】:

我必须通过删除C:\Users\Ramitha\AppData\Roaming\npm-cache_logs 中的npm-cache_logs 文件夹的内容并重新安装eslint 模块来修复错误

【讨论】:

    【解决方案2】:

    npm 缓存清理 --force

    帮我解决了问题

    【讨论】:

      猜你喜欢
      • 2016-08-07
      • 2018-09-04
      • 2017-06-22
      • 2021-05-14
      • 2020-05-27
      • 2021-12-07
      • 2017-01-21
      • 1970-01-01
      • 2011-11-14
      相关资源
      最近更新 更多