Adam Libonatti-Roche
Adam Libonatti-Roche

Reputation: 321

Newbie to Node.Js and NPM

Wanting to create a project using node.js over christmas, and am using a tutorial from this months .Net magazine to help me out. Written by Henrik Joretag I thought it would be simple enough, but I seem to have hit a problem at the first hurdle.

On writing a package.json file, I then try to run it. I am greeted with the following error.

error TypeError: Cannot call method 'replace' of undefined
error     at /usr/local/lib/node_modules/npm/node_modules/read-package-json/read-    json.js:332:45
error     at fs.js:117:20
error     at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:53:5
error     at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:62:5
error     at Object.oncomplete (fs.js:297:15)

I am completely lost on how to configure this as the tutorial has stated that after creating a package.json file it should just work. My package.json looks like this.

{
    "name": "sample-dashboard.iwishiwaschucknorris.com",
    "version" : "0.0.1",
    "homepage" : "http://sample-dashboard.iwishiwaschucknorris.com",
    "description" : "Mind-meldification for teams",
    "dependencies" : {
        "backbone" : "",
        "underscore" : "",
        "express" : "",
        "stitch" : "",
        "andbang-express-auth" : "",
        "precommit-hook" : "",
        "clientmodules" : "",
        "templatizer" : "",
        "andlog" : "",
        "getconfig" : "",
        "connect-githead" : ""
    },
    "clientmodules" : ["andlog","backbone","underscore"],
    "main" : "server.js",
    "scripts" : {
        "postinstall" : "node node_modules/clientmodules/install.js"
    }
}

Any help with this would be great as I really want to get my teeth into node and backbone.js.

Upvotes: 0

Views: 1090

Answers (3)

mcolley73
mcolley73

Reputation: 91

I had this same issue.

Based on this post, I found that I had done a git init but needed to go a bit further for npm to be happy.

I went ahead and did a git add . and a git commit -m "<msg>" in the directory to get my first commit recorded in the git metadata. I then reran the npm install and all was well.

Upvotes: 2

edef
edef

Reputation: 752

This is probably an old npm bug we fixed recently. npm update -g npm and you'll be all set. (it happens when there's a .git but no git HEAD)

Upvotes: 0

H_I
H_I

Reputation: 385

Maybe you just don't run npm install from within the directory of package.json, which will install locally all the dependencies declared in package.json, and run the postinstall script.

Upvotes: 0

Related Questions