在附近解析时,位置 XXX 处 JSON 中出现意外标记的错误
Posted
技术标签:
【中文标题】在附近解析时,位置 XXX 处 JSON 中出现意外标记的错误【英文标题】:Errors of Unexpected token in JSON at position XXX while parsing near 【发布时间】:2021-01-08 18:07:29 【问题描述】:我 npm install
在一个带有 package.json
的目录上,用于我的公司项目。但是,它不断给我 Unexpected token in JSON at position...
的各种错误。
按照When I run `npm install`, it returns with `ERR! code EINTEGRITY` (npm 5.3.0) 的建议,我已经完成了npm cache clean --force
、npm cache verify
等操作
但是,问题仍然存在。我没有配置代理,因为我的机器不在任何公司代理上。
反正我附上npm日志内容和package.json文件内容供大家参考。请帮助告诉我出了什么问题以及如何解决此问题。
npm 日志:
122 silly pacote range manifest for array-includes@^3.1.1 fetched in 64ms
123 http fetch GET 304 https://registry.npmjs.org/typescript 459ms (from cache)
124 silly pacote range manifest for popper.js@^1.14.1 fetched in 109ms
125 warn deprecated popper.js@1.16.1: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1
126 silly fetchPackageMetaData error for typescript@^3.8.3 Unexpected token in JSON at position 831531 while parsing near '...k+EIAF5TJm/AB3lmH1Ƃ�,Xj��ZY��x4YSZvSI...'
127 http fetch GET 304 https://registry.npmjs.org/array.prototype.flat 96ms (from cache)
128 silly pacote range manifest for array.prototype.flat@^1.2.3 fetched in 99ms
129 http fetch GET 304 https://registry.npmjs.org/contains-path 94ms (from cache)
130 silly pacote range manifest for contains-path@^0.1.0 fetched in 95ms
131 http fetch GET 304 https://registry.npmjs.org/debug 85ms (from cache)
132 http fetch GET 304 https://registry.npmjs.org/doctrine 75ms (from cache)
133 silly pacote range manifest for debug@^2.6.9 fetched in 89ms
134 silly pacote version manifest for doctrine@1.5.0 fetched in 79ms
...
307 http fetch GET 304 https://registry.npmjs.org/rxjs 71ms (from cache)
308 silly fetchPackageMetaData error for rxjs@^6.6.0 Unexpected token in JSON at position 133105 while parsing near '...\r\n-----END PGP8'�� C��m�4���
r\n","e...'
309 silly pacote range manifest for through@^2.3.6 fetched in 60ms
310 http fetch GET 304 https://registry.npmjs.org/deep-is 51ms (from cache)
...
479 silly pacote range manifest for typescript-eslint-parser@^18.0.0 fetched in 9ms
480 silly resolveWithNewModule typescript-eslint-parser@18.0.0 checking installable status
481 http fetch GET 304 https://registry.npmjs.org/typescript 67ms (from cache)
482 silly fetchPackageMetaData error for typescript@^3.8.3 Unexpected token in JSON at position 831531 while parsing near '...k+EIAF5TJm/AB3lmH1Ƃ�,Xj��ZY��x4YSZvSI...'
483 timing stage:rollbackFailedOptional Completed in 1ms
484 timing stage:runTopLevelLifecycles Completed in 2633ms
485 silly saveTree typescript-type-definitions@1.0.0
...
485 silly saveTree ├── prettier@1.19.1
485 silly saveTree └── typescript-eslint-parser@18.0.0
486 verbose stack SyntaxError: Unexpected token in JSON at position 831531 while parsing near '...k+EIAF5TJm/AB3lmH1Ƃ�,Xj��ZY��x4YSZvSI...'
486 verbose stack at JSON.parse (<anonymous>)
486 verbose stack at parseJson (/usr/local/lib/node_modules/npm/node_modules/json-parse-better-errors/index.js:7:17)
486 verbose stack at consumeBody.call.then.buffer (/usr/local/lib/node_modules/npm/node_modules/node-fetch-npm/src/body.js:96:50)
486 verbose stack at process._tickCallback (internal/process/next_tick.js:68:7)
487 verbose cwd /home/rugrat/Projects/aleng/ui/includes
488 verbose Linux 4.4.0-189-generic
489 verbose argv "/usr/bin/node" "/usr/local/bin/npm" "install"
490 verbose node v10.22.0
491 verbose npm v6.14.8
492 error Unexpected token in JSON at position 831531 while parsing near '...k+EIAF5TJm/AB3lmH1Ƃ�,Xj��ZY��x4YSZvSI...'
493 verbose exit [ 1, true ]
包.json:
"name": "typescript-type-definitions",
"version": "1.0.0",
"description": "Type definitions for TypeScript",
"main": "typescript/main.js",
"dependencies": ,
"devDependencies":
"@types/bootbox": "^4.4.36",
"@types/bootstrap": "^4.3.2",
"@types/bootstrap-3-typeahead": "^4.0.1",
"@types/bootstrap-select": "^1.11.1",
"@types/bootstrap-switch": "0.0.31",
"@types/bootstrap-toggle": "^2.2.1",
"@types/bootstrap-treeview": "^1.20.0",
"@types/d3": "^5.7.2",
"@types/datatables.net": "^1.10.19",
"@types/datatables.net-select": "^1.2.6",
"@types/jquery": "^1.10.35",
"@types/jquerymobile": "^1.4.30",
"@types/jqueryui": "^1.12.8",
"@types/x-editable": "^1.5.29",
"apidoc": "^0.25.0",
"eslint": "^6.8.0",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-typescript": "^0.12.0",
"prettier": "^1.19.1",
"typescript": "^3.8.3",
"typescript-eslint-parser": "^18.0.0"
,
"scripts":
"test": "echo \"Error: no test specified\" && exit 1"
,
"author": "XXX XXX",
"license": "ISC"
我还在下面添加了npm config
和npm config ls -l
的输出。
npm config
的输出:
; cli configs
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.8 node/v10.22.0 linux x64"
; builtin config undefined
globalconfig = "/etc/npmrc"
globalignorefile = "/etc/npmignore"
prefix = "/usr/local"
; node bin location = /usr/bin/node
; cwd = /home/myname
; HOME = /home/myname
; "npm config ls -l" to show all defaults.
npm config ls -l
的输出:
; cli configs
long = true
metrics-registry = "https://registry.npmjs.org/"
scope = ""
user-agent = "npm/6.14.8 node/v10.22.0 linux x64"
; builtin config undefined
globalconfig = "/etc/npmrc"
globalignorefile = "/etc/npmignore"
prefix = "/usr/local"
; default values
access = null
allow-same-version = false
also = null
always-auth = false
audit = true
audit-level = "low"
auth-type = "legacy"
before = null
bin-links = true
browser = null
ca = null
cache = "/home/myname/.npm"
cache-lock-retries = 10
cache-lock-stale = 60000
cache-lock-wait = 10000
cache-max = null
cache-min = 10
cafile = undefined
cert = null
cidr = null
color = true
commit-hooks = true
depth = null
description = true
dev = false
dry-run = false
editor = "vi"
engine-strict = false
fetch-retries = 2
fetch-retry-factor = 10
fetch-retry-maxtimeout = 60000
fetch-retry-mintimeout = 10000
force = false
format-package-lock = true
fund = true
git = "git"
git-tag-version = true
global = false
global-style = false
; globalconfig = "/usr/local/etc/npmrc" (overridden)
; globalignorefile = "/usr/local/etc/npmignore" (overridden)
group = 1000
ham-it-up = false
heading = "npm"
https-proxy = null
if-present = false
ignore-prepublish = false
ignore-scripts = false
init-author-email = ""
init-author-name = ""
init-author-url = ""
init-license = "ISC"
init-module = "/home/myname/.npm-init.js"
init-version = "1.0.0"
json = false
key = null
legacy-bundling = false
link = false
local-address = undefined
loglevel = "notice"
logs-max = 10
; long = false (overridden)
maxsockets = 50
message = "%s"
; metrics-registry = null (overridden)
node-options = null
node-version = "10.22.0"
noproxy = null
offline = false
onload-script = null
only = null
optional = true
otp = null
package-lock = true
package-lock-only = false
parseable = false
prefer-offline = false
prefer-online = false
; prefix = "/usr" (overridden)
preid = ""
production = false
progress = true
proxy = null
read-only = false
rebuild-bundle = true
registry = "https://registry.npmjs.org/"
rollback = true
save = true
save-bundle = false
save-dev = false
save-exact = false
save-optional = false
save-prefix = "^"
save-prod = false
scope = ""
script-shell = null
scripts-prepend-node-path = "warn-only"
searchexclude = null
searchlimit = 20
searchopts = ""
searchstaleness = 900
send-metrics = false
shell = "/bin/bash"
shrinkwrap = true
sign-git-commit = false
sign-git-tag = false
sso-poll-frequency = 500
sso-type = "oauth"
strict-ssl = true
tag = "latest"
tag-version-prefix = "v"
timing = false
tmp = "/tmp"
umask = 2
unicode = true
unsafe-perm = true
update-notifier = true
usage = false
user = 0
; user-agent = "npm/npm-version node/node-version platform arch ci" (overridden)
userconfig = "/home/myname/.npmrc"
version = false
versions = false
viewer = "man"
我在/usr/lib/node_modules/npm
中找到了.npmrc
,它是空的。
我在/usr/local/lib/node_modules/npm
中找到了npmrc
及其内容:
globalconfig=/etc/npmrc
globalignorefile=/etc/npmignore
prefix=/usr/local
你从上面的内容中发现了什么奇怪的地方吗?我阅读了npm-config 和npmrc,但找不到任何有用的东西。
谢谢。
【问题讨论】:
【参考方案1】:我遇到了同样的错误,我删除了我的 package-lock.json 文件和我的 node_module 文件夹并且它工作了。
【讨论】:
以上是关于在附近解析时,位置 XXX 处 JSON 中出现意外标记的错误的主要内容,如果未能解决你的问题,请参考以下文章
SyntaxError:在 Graphiql 中测试时,JSON 中位置 0 处出现意外标记 <
通过 npm 安装 firebase 时遇到错误 |在 [关闭] 附近解析时 JSON 输入意外结束
创建反应应用程序:npm 错误!在“....”附近解析时 JSON 输入意外结束