解析附近时,JSON中位于XXX位置的意外标记出现错误



Inpm install位于我公司项目的package.json目录中。然而,它不断地给我Unexpected token in JSON at position...的各种错误。

我已经按照建议完成了npm cache clean --forcenpm cache verify等。当我运行`npm install`时,它会返回`ERR!代码EINTEGRITY`(npm 5.3.0(

然而,这个问题仍然存在。虽然我不配置代理,因为我的机器不在任何公司代理上。

无论如何,我附上了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 '...rn-----END PGP8'�� C��m�4���
rn"},"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 ]

Package.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 confignpm 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配置和npmrc,但找不到任何有用的东西。

谢谢。

我也遇到了同样的错误,我删除了package-lock.json文件和node_module文件夹,它成功了。

最新更新