title: Errors of Unexpected token in JSON at position XXX while parsing near
body: <p>I <code>npm install</code> on a directory with a <code>package.json</code> for my company project. However, it keeps giving me various errors of <code> Unexpected token in JSON at position...</code>.</p>
  <p>I have done <code>npm cache clean --force</code>, <code>npm cache verify</code> etc. as suggested by <a href="https://stackoverflow.com/questions/47545940/when-i-run-npm-install-it-returns-with-err-code-eintegrity-npm-5-3-0">When I run `npm install`, it returns with `ERR! code EINTEGRITY` (npm 5.3.0)</a></p>
  <p>
  However, the issue still persists. I do not configure proxy though as my machine is not on any corporate proxy.
  <p>
  Anyway, I attach the npm log content and package.json file content for your reference. Please kindly help to advise me what's wrong and how to resolve this issue.
  <p>npm log:</p>
  <pre><code>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&quot;},&quot;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 (&lt;anonymous&gt;)
  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 &quot;/usr/bin/node&quot; &quot;/usr/local/bin/npm&quot; &quot;install&quot;
  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 ]
  </code></pre>
  <p>Package.json:</p>
  <pre><code>{
    &quot;name&quot;: &quot;typescript-type-definitions&quot;,
    &quot;version&quot;: &quot;1.0.0&quot;,
    &quot;description&quot;: &quot;Type definitions for TypeScript&quot;,
    &quot;main&quot;: &quot;typescript/main.js&quot;,
    &quot;dependencies&quot;: {},
    &quot;devDependencies&quot;: {
      &quot;@types/bootbox&quot;: &quot;^4.4.36&quot;,
      &quot;@types/bootstrap&quot;: &quot;^4.3.2&quot;,
      &quot;@types/bootstrap-3-typeahead&quot;: &quot;^4.0.1&quot;,
      &quot;@types/bootstrap-select&quot;: &quot;^1.11.1&quot;,
      &quot;@types/bootstrap-switch&quot;: &quot;0.0.31&quot;,
      &quot;@types/bootstrap-toggle&quot;: &quot;^2.2.1&quot;,
      &quot;@types/bootstrap-treeview&quot;: &quot;^1.20.0&quot;,
      &quot;@types/d3&quot;: &quot;^5.7.2&quot;,
      &quot;@types/datatables.net&quot;: &quot;^1.10.19&quot;,
      &quot;@types/datatables.net-select&quot;: &quot;^1.2.6&quot;,
      &quot;@types/jquery&quot;: &quot;^1.10.35&quot;,
      &quot;@types/jquerymobile&quot;: &quot;^1.4.30&quot;,
      &quot;@types/jqueryui&quot;: &quot;^1.12.8&quot;,
      &quot;@types/x-editable&quot;: &quot;^1.5.29&quot;,
      &quot;apidoc&quot;: &quot;^0.25.0&quot;,
      &quot;eslint&quot;: &quot;^6.8.0&quot;,
      &quot;eslint-plugin-import&quot;: &quot;^2.20.2&quot;,
      &quot;eslint-plugin-typescript&quot;: &quot;^0.12.0&quot;,
      &quot;prettier&quot;: &quot;^1.19.1&quot;,
      &quot;typescript&quot;: &quot;^3.8.3&quot;,
      &quot;typescript-eslint-parser&quot;: &quot;^18.0.0&quot;
    },
    &quot;scripts&quot;: {
      &quot;test&quot;: &quot;echo \&quot;Error: no test specified\&quot; &amp;&amp; exit 1&quot;
    },
    &quot;author&quot;: &quot;XXX XXX&quot;,
    &quot;license&quot;: &quot;ISC&quot;
  }
  </code></pre>
  <p>I also added the output for <code>npm config</code> and <code>npm config ls -l</code> below.</p>
  <p>Output for <code>npm config</code>:</p>
  <pre><code>; cli configs
  metrics-registry = &quot;https://registry.npmjs.org/&quot;
  scope = &quot;&quot;
  user-agent = &quot;npm/6.14.8 node/v10.22.0 linux x64&quot;
  
  ; builtin config undefined
  globalconfig = &quot;/etc/npmrc&quot;
  globalignorefile = &quot;/etc/npmignore&quot;
  prefix = &quot;/usr/local&quot;
  
  ; node bin location = /usr/bin/node
  ; cwd = /home/myname
  ; HOME = /home/myname
  ; &quot;npm config ls -l&quot; to show all defaults.
  </code></pre>
  <p>Output of <code>npm config ls -l</code>:</p>
  <pre><code>; cli configs
  long = true
  metrics-registry = &quot;https://registry.npmjs.org/&quot;
  scope = &quot;&quot;
  user-agent = &quot;npm/6.14.8 node/v10.22.0 linux x64&quot;
  
  ; builtin config undefined
  globalconfig = &quot;/etc/npmrc&quot;
  globalignorefile = &quot;/etc/npmignore&quot;
  prefix = &quot;/usr/local&quot;
  
  ; default values
  access = null
  allow-same-version = false
  also = null
  always-auth = false
  audit = true
  audit-level = &quot;low&quot;
  auth-type = &quot;legacy&quot;
  before = null
  bin-links = true
  browser = null
  ca = null
  cache = &quot;/home/myname/.npm&quot;
  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 = &quot;vi&quot;
  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 = &quot;git&quot;
  git-tag-version = true
  global = false
  global-style = false
  ; globalconfig = &quot;/usr/local/etc/npmrc&quot; (overridden)
  ; globalignorefile = &quot;/usr/local/etc/npmignore&quot; (overridden)
  group = 1000
  ham-it-up = false
  heading = &quot;npm&quot;
  https-proxy = null
  if-present = false
  ignore-prepublish = false
  ignore-scripts = false
  init-author-email = &quot;&quot;
  init-author-name = &quot;&quot;
  init-author-url = &quot;&quot;
  init-license = &quot;ISC&quot;
  init-module = &quot;/home/myname/.npm-init.js&quot;
  init-version = &quot;1.0.0&quot;
  json = false
  key = null
  legacy-bundling = false
  link = false
  local-address = undefined
  loglevel = &quot;notice&quot;
  logs-max = 10
  ; long = false (overridden)
  maxsockets = 50
  message = &quot;%s&quot;
  ; metrics-registry = null (overridden)
  node-options = null
  node-version = &quot;10.22.0&quot;
  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 = &quot;/usr&quot; (overridden)
  preid = &quot;&quot;
  production = false
  progress = true
  proxy = null
  read-only = false
  rebuild-bundle = true
  registry = &quot;https://registry.npmjs.org/&quot;
  rollback = true
  save = true
  save-bundle = false
  save-dev = false
  save-exact = false
  save-optional = false
  save-prefix = &quot;^&quot;
  save-prod = false
  scope = &quot;&quot;
  script-shell = null
  scripts-prepend-node-path = &quot;warn-only&quot;
  searchexclude = null
  searchlimit = 20
  searchopts = &quot;&quot;
  searchstaleness = 900
  send-metrics = false
  shell = &quot;/bin/bash&quot;
  shrinkwrap = true
  sign-git-commit = false
  sign-git-tag = false
  sso-poll-frequency = 500
  sso-type = &quot;oauth&quot;
  strict-ssl = true
  tag = &quot;latest&quot;
  tag-version-prefix = &quot;v&quot;
  timing = false
  tmp = &quot;/tmp&quot;
  umask = 2
  unicode = true
  unsafe-perm = true
  update-notifier = true
  usage = false
  user = 0
  ; user-agent = &quot;npm/{npm-version} node/{node-version} {platform} {arch} {ci}&quot; (overridden)
  userconfig = &quot;/home/myname/.npmrc&quot;
  version = false
  versions = false
  viewer = &quot;man&quot;
  </code></pre>
  <p>I found <code>.npmrc</code> in <code>/usr/lib/node_modules/npm</code> and it is empty.</p>
  <p>I found <code>npmrc</code> in <code>/usr/local/lib/node_modules/npm</code> and its content:</p>
  <pre><code>globalconfig=/etc/npmrc
  globalignorefile=/etc/npmignore
  prefix=/usr/local
  </code></pre>
  <p>Do you find anything odd from the contents above? I read <a href="https://docs.npmjs.com/using-npm/config" rel="noreferrer">npm-config</a> and <a href="https://docs.npmjs.com/files/npmrc" rel="noreferrer">npmrc</a> but can't find anything helpful.</p>
  <p>Thanks.</p>