Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cant install dependencies in node js

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!

like image 667
Jhonnatan Gonzalez Rodriguez Avatar asked Mar 17 '13 21:03

Jhonnatan Gonzalez Rodriguez


1 Answers

You can't have comments in JSON files.

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

like image 81
josh3736 Avatar answered Sep 21 '22 14:09

josh3736