hapijs / good

hapi process monitoring
Other
525 stars 160 forks source link

Error installing | package.json must be actual JSON, not just JavaScript. #532

Closed joseph-ortiz closed 7 years ago

joseph-ortiz commented 7 years ago

I am currently following an egghead.io course on Hapi.js. In the tutorial, we are trying to install the good package through the CLI.

I type in npm install --save good and I end up getting the error below. I looked through the issues and couldn't find a resolution. Any advice would be appreciated.

0 info it worked if it ends with ok
1 verbose cli [ '/home/ubuntu/.nvm/versions/node/v4.6.1/bin/node',
1 verbose cli   '/home/ubuntu/.nvm/versions/node/v4.6.1/bin/npm',
1 verbose cli   'install',
1 verbose cli   '--save',
1 verbose cli   'good' ]
2 info using npm@2.15.9
3 info using node@v4.6.1
4 verbose install initial load of /home/ubuntu/workspace/package.json
5 verbose stack Error: Failed to parse json
5 verbose stack Trailing comma in object at 9:3
5 verbose stack   },
5 verbose stack   ^
5 verbose stack     at parseError (/home/ubuntu/.nvm/versions/node/v4.6.1/lib/node_modules/npm/node_modules/read-package-json/read-json.js:390:11)
5 verbose stack     at parseJson (/home/ubuntu/.nvm/versions/node/v4.6.1/lib/node_modules/npm/node_modules/read-package-json/read-json.js:79:23)
5 verbose stack     at /home/ubuntu/.nvm/versions/node/v4.6.1/lib/node_modules/npm/node_modules/read-package-json/read-json.js:48:5
5 verbose stack     at /home/ubuntu/.nvm/versions/node/v4.6.1/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:78:16
5 verbose stack     at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:380:3)
6 verbose cwd /home/ubuntu/workspace
7 error Linux 4.2.0-c9
8 error argv "/home/ubuntu/.nvm/versions/node/v4.6.1/bin/node" "/home/ubuntu/.nvm/versions/node/v4.6.1/bin/npm" "install" "--save" "good"
9 error node v4.6.1
10 error npm  v2.15.9
11 error file /home/ubuntu/workspace/package.json
12 error code EJSONPARSE
13 error Failed to parse json
13 error Trailing comma in object at 9:3
13 error   },
13 error   ^
14 error File: /home/ubuntu/workspace/package.json
15 error Failed to parse package.json data.
15 error package.json must be actual JSON, not just JavaScript.
15 error
15 error This is not a bug in npm.
15 error Tell the package author to fix their package.json file. JSON.parse
16 verbose exit [ 1, true ]
vdeturckheim commented 7 years ago

Can you copy your package.json file please ?

joseph-ortiz commented 7 years ago

I've added my package.json file and the installed node_module package.json file below. It looks like valid JSON to me.

My Application for hapi-js

{
  "name": "hapi-js-egghead",
  "version": "0.0.0",
  "description": "Hapi.js course on Egghead.io",
  "main": "",
  "author": "Joseph Ortiz",
  "dependencies": {
    "hapi": "^15.2.0",
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "license": "ISC"
}

installed hapi.js module's package.json

{
  "name": "hapi",
  "description": "HTTP Server framework",
  "homepage": "http://hapijs.com",
  "version": "15.2.0",
  "repository": {
    "type": "git",
    "url": "git://github.com/hapijs/hapi.git"
  },
  "main": "lib/index.js",
  "keywords": [
    "framework",
    "http",
    "api",
    "web"
  ],
  "engines": {
    "node": ">=4.5.0"
  },
  "dependencies": {
    "accept": "2.x.x",
    "ammo": "2.x.x",
    "boom": "4.x.x",
    "call": "3.x.x",
    "catbox": "7.x.x",
    "catbox-memory": "2.x.x",
    "cryptiles": "3.x.x",
    "heavy": "4.x.x",
    "hoek": "4.x.x",
    "iron": "4.x.x",
    "items": "2.x.x",
    "joi": "9.x.x",
    "mimos": "3.x.x",
    "podium": "^1.2.x",
    "shot": "3.x.x",
    "statehood": "5.x.x",
    "subtext": "^4.3.x",
    "topo": "2.x.x"
  },
  "devDependencies": {
    "code": "4.x.x",
    "handlebars": "4.x.x",
    "inert": "4.x.x",
    "lab": "11.x.x",
    "vision": "4.x.x",
    "wreck": "10.x.x"
  },
  "scripts": {
    "test": "lab -a code -t 100 -L -m 3000",
    "test-tap": "lab -a code -r tap -o tests.tap -m 3000",
    "test-cov-html": "lab -a code -r html -o coverage.html -m 3000"
  },
  "license": "BSD-3-Clause",
  "gitHead": "d2735a516ffafebaca08d76cb26c8c3af2142b06",
  "bugs": {
    "url": "https://github.com/hapijs/hapi/issues"
  },
  "_id": "hapi@15.2.0",
  "_shasum": "5704ca2c04b6386c03caf9ee901f1de080316d23",
  "_from": "hapi@>=15.2.0 <16.0.0",
  "_npmVersion": "3.10.8",
  "_nodeVersion": "6.5.0",
  "_npmUser": {
    "name": "hueniverse",
    "email": "eran@hammer.io"
  },
  "dist": {
    "shasum": "5704ca2c04b6386c03caf9ee901f1de080316d23",
    "tarball": "https://registry.npmjs.org/hapi/-/hapi-15.2.0.tgz"
  },
  "maintainers": [
    {
      "name": "hueniverse",
      "email": "eran@hueniverse.com"
    }
  ],
  "_npmOperationalInternal": {
    "host": "packages-12-west.internal.npmjs.com",
    "tmp": "tmp/hapi-15.2.0.tgz_1476983631556_0.7504958582576364"
  },
  "directories": {},
  "_resolved": "https://registry.npmjs.org/hapi/-/hapi-15.2.0.tgz",
  "readme": "ERROR: No README data found!"
}
vdeturckheim commented 7 years ago

Can you remove the comma at the end of the line

"hapi": "^15.2.0",

in your file ? I should work after that.

joseph-ortiz commented 7 years ago

yeah, i decided to actualy JSONlint my package.json file and found the same problem. thank you!

rahada commented 6 years ago

have same issue here and trying to remove name and didn't work

{
  "name": "talent",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.0.3",
    "@angular/common": "^6.0.3",
    "@angular/compiler": "^6.0.3",
    "@angular/core": "^6.0.3",
    "@angular/forms": "^6.0.3",
    "@angular/http": "^6.0.3",
    "@angular/platform-browser": "^6.0.3",
    "@angular/platform-browser-dynamic": "^6.0.3",
    "@angular/router": "^6.0.3",
    //"angularfire2": "^5.0.0-rc.10",
    "@ng-bootstrap/ng-bootstrap": "^2.0.0",
    "angular2-image-upload": "^1.0.0-rc.1",
    "bootstrap": "^4.1.1",
    "core-js": "^2.5.4",
    "firebase":"^5.0.3",
    "ngx-bootstrap": "^3.0.0",
    "rxjs": "^6.0.0",
    "rxjs-compat": "^6.2.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^6.0.3",
    "@angular-devkit/build-angular": "~0.6.5",
    "typescript": "~2.7.2",
    "@angular/cli": "~6.0.5",
    "@angular/language-service": "^6.0.3",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~1.4.2",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1"
  }
}
Marsup commented 6 years ago

Edited your comment to make it readable, I think the red part speaks for itself.

dreampoetlee commented 5 years ago

Hello, I am trying to install npm install jquery --save to one of my repos but I keep getting the following issues. I've tried to clean the cache and verify it as well but nothing is working. Can someone please help me fix this? npm error

Marsup commented 5 years ago

Protip: Don't hijack issues of some random project you found on the internet just because it matched a few keywords.

Also, actually read what you found, especially when the issue is already closed and already contains the answer.