Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM | Error while installing modules

Tags:

node.js

npm

When I try to install some modules I get this error:

npm ERR! Unexpected end of JSON input while parsing near '..."hjs":"~0.0.6","marke'

npm ERR! A complete log of this run can be found in: npm ERR!
C:\Users\omare\AppData\Roaming\npm-cache_logs\2018-07-30T09_21_21_147Z-debug.log

And in the log file I get this:

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   'i',
1 verbose cli   'express' ]
2 info using [email protected]
3 info using [email protected]
4 verbose npm-session 1b65207ea7164d4e
5 silly install loadCurrentTree
6 silly install readLocalPackageData
7 http fetch GET 304 https://registry.npmjs.org/express 1289ms (from cache)
8 silly fetchPackageMetaData error for express@^4.15.3 Unexpected end of JSON input while parsing near '..."hjs":"~0.0.6","marke'
9 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '..."hjs":"~0.0.6","marke'
9 verbose stack     at JSON.parse (<anonymous>)
9 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)
9 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)
9 verbose stack     at <anonymous>
9 verbose stack     at process._tickCallback (internal/process/next_tick.js:188:7)
10 verbose cwd H:\Projects\WEB Development\My Stuff\Nuxt
11 verbose Windows_NT 10.0.17134
12 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "i" "express"
13 verbose node v8.11.3
14 verbose npm  v5.6.0
15 error Unexpected end of JSON input while parsing near '..."hjs":"~0.0.6","marke'
16 verbose exit [ 1, true ]

My package.json file:

{
  "name": "mevn",
  "version": "1.0.0",
  "description": "MongoDb, Express, Vue.js, and Node.js stack workflow",
  "main": "app.js",
  "scripts": {
    "start-server": "node server/bin/www",
    "dev": "webpack-dev-server --inline --progress --config Client/build/webpack.dev.conf.js",
    "start-client": "npm run dev",
    "build-client": "node Client/build/build.js"
  },
  "repository": {
    "type": "git",
    "url": "git+https://github.com/Omar-Hussein/MEVN.git"
  },
  "keywords": [
    "workflow",
    "mevn",
    "mongodb",
    "express",
    "node",
    "vue"
  ],
  "author": "Omar Hussein",
  "license": "WTFPL",
  "bugs": {
    "url": "https://github.com/Omar-Hussein/MEVN/issues"
  },
  "homepage": "https://github.com/Omar-Hussein/MEVN#readme",
  "engines": {
    "node": ">= 6.0.0",
    "npm": ">= 3.0.0"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ],
  "dependencies": {
    "axios": "^0.18.0",
    "connect-mongo": "^2.0.1",
    "cors": "~2.8.4",
    "debug": "^3.1.0",
    "express-session": "^1.15.6",
    "express-validator": "^5.3.0",
    "http-errors": "^1.6.3",
    "lodash": "^4.17.10",
    "mongoose": "^5.2.5",
    "morgan": "^1.9.0",
    "vue": "^2.5.16",
    "vue-router": "^3.0.1",
    "vuetify": "^1.1.8",
    "vuex": "^3.0.1",
    "vuex-persistedstate": "^2.5.4",
    "vuex-router-sync": "^5.0.0"
  },
  "devDependencies": {
    "autoprefixer": "^9.0.1",
    "babel": "^6.23.0",
    "babel-helper-vue-jsx-merge-props": "^2.0.3",
    "babel-loader": "^7.1.5",
    "babel-plugin-syntax-jsx": "^6.18.0",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-plugin-transform-vue-jsx": "^3.7.0",
    "babel-preset-env": "^1.7.0",
    "babel-preset-stage-2": "^6.24.1",
    "chalk": "^2.4.1",
    "copy-webpack-plugin": "^4.5.2",
    "css-loader": "^1.0.0",
    "extract-text-webpack-plugin": "^3.0.2",
    "file-loader": "^1.1.11",
    "friendly-errors-webpack-plugin": "^1.7.0",
    "html-webpack-plugin": "^3.2.0",
    "material-design-icons-iconfont": "^3.0.3",
    "node-notifier": "^5.2.1",
    "optimize-css-assets-webpack-plugin": "^5.0.0",
    "ora": "^3.0.0",
    "portfinder": "^1.0.13",
    "postcss-import": "^11.1.0",
    "postcss-loader": "^2.1.6",
    "postcss-url": "^7.3.2",
    "rimraf": "^2.6.2",
    "semver": "^5.5.0",
    "shelljs": "^0.8.2",
    "uglifyjs-webpack-plugin": "^1.2.7",
    "url-loader": "^1.0.1",
    "vue-loader": "^15.2.6",
    "vue-style-loader": "^4.1.1",
    "vue-template-compiler": "^2.5.16",
    "webpack": "^4.16.3",
    "webpack-merge": "^4.1.3"
  }
}

info:

  • OS: Windows 10
  • Node: v 8.11.3
  • NPM: v 5.6.0

Some of the modules I get this error from:

  • express
  • connect-flash
  • webpack-bundle-analyzer
  • webpack-dev-server
like image 388
Omar Hussein Avatar asked Dec 11 '22 05:12

Omar Hussein


1 Answers

Try executing,

npm cache clean

And then do a,

npm install

Hope this helps!

like image 98
David R Avatar answered Jan 14 '23 21:01

David R