skip to Main Content

I’m trying to run npm install and I get this:

root@WF-DEV1:/var/www/laravel# npm install                                                                                                                              
npm ERR! install Couldn't read dependencies                                                                                                                             
npm ERR! Failed to parse json                                                                                                                                           
npm ERR! Unexpected token }                                                                                                                                             
npm ERR! File: /var/www/laravel/package.json                                                                                                                            
npm ERR! Failed to parse package.json data.                                                                                                                             
npm ERR! package.json must be actual JSON, not just JavaScript.                                                                                                         
npm ERR!                                                                                                                                                                
npm ERR! This is not a bug in npm.                                                                                                                                      
npm ERR! Tell the package author to fix their package.json file. JSON.parse  

This is my package.json file:

{
  "name": "bootstrap-tagsinput",
  "title": "Bootstrap Tags Input",
  "version": "0.5.0",
  "description": "jQuery plugin providing a Twitter Bootstrap user interface for managing tags.",
  "scripts": {
    "test": "karma start --single-run --no-auto-watch"
  },
  "main" : "dist/bootstrap-tagsinput.js",
  "repository": {
    "type": "git",
    "url": "git://github.com/timschlechter/bootstrap-tagsinput.git"
  },
  "author": "Tim Schlechter",
  "contributors": [{
      "name": "Luckner Jr Jean-Baptiste"
   }],
  "license": "MIT",
  "homepage": "http://timschlechter.github.io/bootstrap-tagsinput/examples/",
  "download": "http://timschlechter.github.io/bootstrap-tagsinput/build/bootstrap-tagsinput.zip",
  "keywords": [
    "tags",
    "bootstrap",
    "input",
    "select",
    "form"
  ],
  "readmeFilename": "README.md",
  "devDependencies": {
    "grunt": "~0.4.1",
    "grunt-cli": "~0.1.13",
    "grunt-contrib-copy": "~0.5.0",
    "grunt-contrib-uglify": "~0.2.2",
    "grunt-jquerymanifest": "~0.1.4",
    "grunt-zip": "~0.15.0",
    "karma": "~0.12.19",
    "phantomjs": "~1.9.7-15",
    "karma-phantomjs-launcher": "~0.1.3",
    "karma-jasmine": "~0.1.5",
    "grunt-karma": "~0.8.3",
    "bower": "~1.3.8",
    "grunt-bower-task": "~0.4.0"
  },
  "banner": "/*n * <%= pkg.name %> v<%= pkg.version %> by <%= pkg.author %>n * <%= pkg.license.url %>n */n"
}

Any help would be appreciated!

2

Answers


  1. Chosen as BEST ANSWER

    For some reason, the wrong code was in my package.json. Not sure how it got there but I definitely didn't put it there. I reinstalled everything and it's now fixed and the right code is in there now.


  2. The JSON appears to be valid (I ran it through an online parser). I ran the same package.json under windows and got the following output:

    D:workspacedeleteme>npm install
    npm ERR! install Couldn't read dependencies
    npm ERR! Windows_NT 10.0.10240
    npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "install"
    npm ERR! node v4.1.1
    npm ERR! npm  v2.14.4
    npm ERR! file D:workspacedeletemepackage.json
    npm ERR! code EJSONPARSE
    
    npm ERR! Failed to parse json
    npm ERR! Unexpected token '<' at 1:1
    npm ERR! <!DOCTYPE html>
    npm ERR! ^
    npm ERR! File: D:workspacedeletemepackage.json
    npm ERR! Failed to parse package.json data.
    npm ERR! package.json must be actual JSON, not just JavaScript.
    npm ERR!
    npm ERR! This is not a bug in npm.
    npm ERR! Tell the package author to fix their package.json file. JSON.parse
    
    npm ERR! Please include the following file with any support request:
    npm ERR!     D:workspacedeletemenpm-debug.log
    

    The npm-debug.log started with:

    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' ]
    2 info using [email protected]
    3 info using [email protected]
    4 verbose readDependencies loading dependencies from D:workspacedeletemepackage.json
    5 error install Couldn't read dependencies
    6 verbose stack Error: Failed to parse json
    6 verbose stack Unexpected token '<' at 1:1
    6 verbose stack <!DOCTYPE html>
    6 verbose stack ^
    6 verbose stack     at parseError (C:Program Filesnodejsnode_modulesnpmnode_modulesread-package-jsonread-json.js:379:11)
    6 verbose stack     at parseJson (C:Program Filesnodejsnode_modulesnpmnode_modulesread-package-jsonread-json.js:68:23)
    6 verbose stack     at C:Program Filesnodejsnode_modulesnpmnode_modulesread-package-jsonread-json.js:48:5
    6 verbose stack     at C:Program Filesnodejsnode_modulesnpmnode_modulesgraceful-fsgraceful-fs.js:76:16
    6 verbose stack     at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
    7 verbose cwd D:workspacedeleteme
    

    So on a hunch, I changed your devDependencies to dependencies and that worked. So I don’t have a firm answer, but it seems there is definitely something in your file that npm has a problem with – it’s just not a JSON error.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search