Ramon Vasconcelos
Ramon Vasconcelos

Reputation: 945

Error installing starting a project with grunt

I'm trying to start a new project using gruntjs.

I have this project structure:

grunt-test (dir)
  |_ index.html
  |_ package.json
  |_ Gruntfile.js
  |_ assets (dir)
    |_ _js (dir)
      |_ scripts.js
    |_ _sass (dir)
      |_ style.sass

I have nodejs and grunt installed.

So, when I go to project's folder and use this command line on terminal: npm install grunt --save-dev

It returns me all those errors:

npm ERR! Failed to parse json
npm ERR! Unexpected end of input
npm ERR! File: /Applications/XAMPP/xamppfiles/htdocs/grunt-test/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 11.4.2
npm ERR! command "node" "/usr/local/bin/npm" "install" "grunt" "--save-dev"
npm ERR! cwd /Applications/XAMPP/xamppfiles/htdocs/grunt-test
npm ERR! node -v v0.10.26
npm ERR! npm -v 1.4.3
npm ERR! file /Applications/XAMPP/xamppfiles/htdocs/grunt-test/package.json
npm ERR! code EJSONPARSE
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Applications/XAMPP/xamppfiles/htdocs/grunt-test/npm-debug.log
npm ERR! not ok code 0

I've been trying to install it for a while and I haven't had any success. I don't know what I'm doing wrong. I'm following all the instructions on gruntjs docs. Can someone help me?

Upvotes: 0

Views: 767

Answers (2)

ebrehault
ebrehault

Reputation: 2601

In your package.json, strings are enclosed into single quotes ('), it makes it a non-valid JSON data. JSON expects strings to be enclosed into double quotes (").

Upvotes: 0

user235273
user235273

Reputation:

Your package.json is not a valid JSON. Instead of typing in commands, you can add these as devDependencies in your package.json file and then use npm install which will install packages from the package.json file. You can use the below.

{
    "name": "Project Name",
    "version": "1.0.0",
    "devDependencies": {
        "grunt": "0.4.4",
        "grunt-cli": "0.1.13"
    }
}

Run npm install grunt-cli -g if grunt is not found message gets displayed.

Upvotes: 2

Related Questions