1

I want to npm install the following validate .json

{
    "name": "node-todo",
    "version": "0.0.0",
    "description": "Simple todo application",
    "main": "server.js",
    "dependencies": {
        "express": "~3.4.4",
        "mongoose": "~3.6.2"
    }, 
    "private": true
}

but the npm install doesn't seem to work because I even cant npm install a sample json from http://package-json-validator.com/

I installed npm and nodejs with the following commands

echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://npmjs.org/install.sh | sh

Now I want to use npm install but the shell gives me this npm ERR! install Couldn't read dependencies npm ERR! Failed to parse json npm ERR! Unexpected token / 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 13.0.0
npm ERR! node -v v0.10.22
npm ERR! npm -v 1.3.14
npm ERR! code EJSONPARSE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR! not ok code 0

I'm using Sublime and saved the json as a UTF-8 (without the BOM tag)

3
  • well i tried this at the beginning, but didn't work for me either. Commented Nov 15, 2013 at 11:54
  • Sorry about removing my comment :) It didn't work with the exact same reason? I have no issues whatsoever with the official installer (or to run your package.json). Did you check npm-debug.log to see for any additional clues? Commented Nov 15, 2013 at 11:55
  • ah it worked now, i save UTF-8 without BOM in the false directory Commented Nov 15, 2013 at 12:07

2 Answers 2

4

Assuming you are running ubuntu or that you are using the aptitude package manager

apt-get install -y python-software-properties python g++ make
add-apt-repository ppa:chris-lea/node.js
apt-get install nodejs
apt-get install npm

Then run this when needed to update the sources.list and install the latest version.

apt-get update
apt-get upgrade nodejs

If you want to downgrade node simply use

apt-get install nodejs={version number}
Sign up to request clarification or add additional context in comments.

Comments

1

Linux Installation - node.js:

  • Via package manager for many distros:
    https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

    Or

  • Via download binaries (this worked for me after many problems with other solutions)

    a) download from https://nodejs.org/download/release/latest/
    b) move to /usr/local/

    Note: To avoid permissions problems when install none modules globally (npm install -g ...) you must to move files preserving your ownership.

    i) Unpack as normal user, ie, not sudo:
    tar -zxvf node-package.tar.gz

    ii) Move properly (-p same as -preserve=mode,ownership,timestamps):
    sudo cp -rp node-package/* /usr/local/ && rm -rf node-package

enter image description here

Linux Installation - npm

  • Be sure you have node.js already installed (node -v):

    curl https://www.npmjs.org/install.sh | sh

    Note: www.npmjs.org/install.sh is the new URL after February 2014

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.