Question

I'm learning node js and I just did a tutorial in which I was trying to create a chat, everything works well until I got stuck in a step of the tutorial. I decided to download the sources of the tutorial to run the server and see what is the problem. I have a folder called curso in this folder I have two folders ones chatnodejs and other is sourcechatjs; in chat nodejs I have packasge.json and server js. I ran npminstall and everything is good, but when I downloaded the chat source I placed it in sourcechatjs I opened the terminal and ran npm install and got this error:

jhonnatans-MacBook-Pro:chat jhonnatan$ npm install
npm ERR! install Couldn't read dependencies
npm ERR! Failed to parse json
npm ERR! Unexpected token /
npm ERR! File: /Users/jhonnatan/Documents/Cursoseccion2/clasenodejs/chat/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

npm ERR! System Darwin 12.3.0  
npm ERR! command "node" "/usr/local/bin/npm" "install"
npm ERR! cwd /Users/jhonnatan/Documents/Cursoseccion2/clasenodejs/chat
npm ERR! node -v v0.10.0
npm ERR! npm -v 1.2.14
npm ERR! file /Users/jhonnatan/Documents/Cursoseccion2/clasenodejs/chat/package.json
npm ERR! code EJSONPARSE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/jhonnatan/Documents/Cursoseccion2/clasenodejs/chat/npm-debug.log
npm ERR! not ok code 0

This is how my JSON looks:

{
    // Aca definiremos nuestro package.json, lo primero es el nombre
    "name": "curso",
    // Luego la version del mismo
    "version": "0.0.1",
    // Ahora las dependencias, normalmente podrias hacer esto con npm pero es mucho mejor tener claro y ejecutar estricatemente las necesaria
    "dependencies": {
        // Express el cual se encargara de ser nuestro framework en node
        "express": "",
        //los tipos de vista, jade parecido al que usa ruby on rails y swig parecido al que usa django
        "jade": "",
        "swig": "",
        // El que se encargara de renderizar los templates en un contexto
        "consolidate": "",
        // y por ultimo el encargado de manejar los sockets :)
        "socket.io": ""
    }
}

I've been trying a lot, but seriously I have no idea of what could be the problem. I will appreciate if someone could let me know the problem!

Was it helpful?

Solution

You can't have comments in JSON files.

Remove the comment lines // ... and it should work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top