tower-archive / tower

UNMAINTAINED - Small components for building apps, manipulating data, and automating a distributed infrastructure.
http://tower.github.io
MIT License
1.79k stars 120 forks source link

Grunt problems #388

Closed mitchpolska closed 10 years ago

mitchpolska commented 11 years ago

Hi, I have installed tower according to instruction (on github) and I have still errors after cake watch: Default database not set, using Memory store Loading "Gruntfile.coffee" tasks... ERROR

TypeError: Object # has no method 'registerHelper' Warning: Task "start" not found. Use --force to continue.

Aborted due to warnings.

I tried some ways but still doesn't work (older versions, dev version, I have even wrote function in grunt registerHelper but after that I had other errors with grunt)

btbinhtran commented 11 years ago
mitchpolska commented 11 years ago

Thank you very much but now I have this errors: Default database not set, using Memory store Running "copy:stylesheets" (copy) task Copied 2 files.

Running "copy:javascripts" (copy) task Copied 35 files.

Running "copy:images" (copy) task Copied 0 files.

Running "coffee:compile" (coffee) task

Running "less:bootstrap" (less) task

TypeError: Object # has no method 'options' at Object.module.exports.grunt.util._.extend.filename (/Users/kopankom/projects/node/tow/node_modules/grunt-contrib-less/tasks/less.js:24:24) at Object.task.registerMultiTask.thisTask (/usr/local/lib/node_modules/grunt/lib/grunt/task.js:109:15) at Object.task.registerTask.thisTask.fn (/usr/local/lib/node_modules/grunt/lib/grunt/task.js:58:16) at Task. (/usr/local/lib/node_modules/grunt/lib/util/task.js:343:36) at Task. (/usr/local/lib/node_modules/grunt/lib/util/task.js:319:9) at Task. (/usr/local/lib/node_modules/grunt/lib/util/task.js:346:11) at Task. (/usr/local/lib/node_modules/grunt/lib/util/task.js:319:9) at Task. (/usr/local/lib/node_modules/grunt/lib/util/task.js:346:11) at Task. (/usr/local/lib/node_modules/grunt/lib/util/task.js:319:9) at Task. (/usr/local/lib/node_modules/grunt/lib/util/task.js:346:11)

btbinhtran commented 11 years ago

Ok, your issue has to do with your grunt-contrib, grunt-contrib-less, and grunt-contrib-stylus package versions.

First, uninstall grunt-contrib, grunt-contrib-less, and grunt-contrib-stylus by running

npm uninstall grunt-contrib-less grunt-contrib-stylus grunt-contrib

Then in your app's package.json you need to change lines:

"grunt-contrib-less": ">= 0.3.0",
"grunt-contrib-stylus": ">= 0.3.0",
"grunt-contrib": ">= 0.2.0",

to

"grunt-contrib-less": "~0.3.2",
"grunt-contrib-stylus": "~0.3.1",
"grunt-contrib": "~0.3.0",

The updated package.json should look almost exactly like this without my name:

{
  "name": "app",
  "private": true,
  "version": "0.1.0",
  "description": "",
  "homepage": "http://User.github.com/app",
  "main": "./server.js",
  "subdomain": "app",
  "author": "'Binh Tran' <btbinhtran@gmail.com>",
  "keywords": [
    "node"
  ],
  "maintainers": [{
    "name": "Binh Tran",
    "email": "btbinhtran@gmail.com"
  }],
  "contributors": [

  ],
  "licenses": [
    {
      "type": "MIT",
      "url": "http://mths.be/mit"
    }
  ],
  "bugs": {
    "url": "https://github.com/User/app/issues"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/User/app.git"
  },
  "engines": {
    "node": ">= 0.6.0",
    "npm": ">= 1"
  },
  "dependencies": {
    "async": ">= 0.1.22",
    "coffee-script": "1.3.3",
    "mongodb": ">= 1.1.10",
    "coffeecup": ">= 0.3.17",
    "socket.io": ">= 0.8.7",
    "socket.io-client": ">= 0.9.5",
    "tower": ">= 0.4.2",
    "which": ">= 1.0.5"
  },
  "optionalDependencies": {
    "nodemailer": ">= 0.3.28",
    "kue": ">= 0.3.4"
  },
  "devDependencies": {
    "chokidar": "~0.4.0",
    "stylus": ">= 0.29.0",
    "Faker": ">= 0.1.3",
    "less": ">= 1.2.2",
    "uglify-js": ">= 1.1.1",
    "mocha": ">= 0.12.1",
    "chai": ">= 0.3.3",
    "sinon": ">= 1.3.1",
    "knox": ">= 0.0.11",
    "gzip": ">= 0.1.0",
    "cli-table": ">= 0.0.1",
    "grunt-contrib-less": "~0.3.2",
    "grunt-contrib-stylus": "~0.3.1",
    "grunt-contrib": "~0.3.0",
    "superagent": ">= 0.9.5",
    "wrench": ">= 1.3.8",
    "fibers": "~0.6.8",
    "ejs": ">= 0.6.1"
  },
  "scripts": {
    "test": "./node_modules/mocha/bin/mocha $(find test -name \"*Test.coffee\")",
    "prepublish": "npm prune; rm -rf node_modules/*/{test,example,bench}*",
    "start": "node server.js -e production"
  },
  "tower": {
    "stylesheets": "styl",
    "scripts": "coffee",
    "templates": "coffee"
  }
}

Now run:

npm install

Run

cake watch

and you should be set.

In the future, these library version issues will be resolved by using the safe package patch versions with "~(version #)" instead of ">= (version #)"

That's the proper way to install packages in Node.js.

mitchpolska commented 11 years ago

Thank you for your response but still doesn't work: ERROR

TypeError: Object # has no method 'registerHelper' Warning: Task "start" not found. Use --force to continue. Aborted due to warnings. I had copied all of your package.json and executed npm install

btbinhtran commented 11 years ago

I was able to get it working with a clean install of Node.js version 0.8.21 with NVM (Node Version Manager).

Try a clean install with NVM and Node.js version 0.8.21 to isolate the problem as much as possible.

If you haven't setup NVM already, see https://github.com/creationix/nvm

With NVM, install Node.js version 0.8.21 by running

nvm install 0.8.21

You should make a default alias to the latest Node.js version by running

nvm alias default 0.8.21

Make sure you are using Node.js version 0.8.21 by running either

nvm use 0.8.21

or

nvm use default

Now you should check you are using Node.js version 0.8.21 by running

node -v

That should output

v0.8.21

Also, check your NPM (Node Package Manager) version by running

npm -v

which should output

1.2.11

If all is good so far, let's install Tower globally by running

npm install tower -g

Next, install Grunt version 0.3.17 globally by running

npm install grunt@0.3.17 -g

Later versions of Grunt are not working with Tower.

Also, install CoffeeScript version 1.4.0 by running

npm install coffee-script@1.4.0 -g

At the moment, only CoffeeScript version 1.4.0 is working well with Tower.

Check your Tower version by running

tower -V

which should output

0.4.2-25

Now, install MongoDB with brew if you haven't installed it yet

brew install mongodb

Run the MongoDB server by running

mongod

After all that installation, let's get started with your first app.

In your terminal, generate your app by running

tower new app

Edit your app's package.json like we discussed earlier.

In your app's package.json you need to change lines:

"grunt-contrib-less": ">= 0.3.0",
"grunt-contrib-stylus": ">= 0.3.0",
"grunt-contrib": ">= 0.2.0",

to

"grunt-contrib-less": "~0.3.2",
"grunt-contrib-stylus": "~0.3.1",
"grunt-contrib": "~0.3.0",

The updated package.json should look almost exactly like this without my name:

{
  "name": "app",
  "private": true,
  "version": "0.1.0",
  "description": "",
  "homepage": "http://User.github.com/app",
  "main": "./server.js",
  "subdomain": "app",
  "author": "'Binh Tran' <btbinhtran@gmail.com>",
  "keywords": [
    "node"
  ],
  "maintainers": [{
    "name": "Binh Tran",
    "email": "btbinhtran@gmail.com"
  }],
  "contributors": [

  ],
  "licenses": [
    {
      "type": "MIT",
      "url": "http://mths.be/mit"
    }
  ],
  "bugs": {
    "url": "https://github.com/User/app/issues"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/User/app.git"
  },
  "engines": {
    "node": ">= 0.6.0",
    "npm": ">= 1"
  },
  "dependencies": {
    "async": ">= 0.1.22",
    "coffee-script": "1.3.3",
    "mongodb": ">= 1.1.10",
    "coffeecup": ">= 0.3.17",
    "socket.io": ">= 0.8.7",
    "socket.io-client": ">= 0.9.5",
    "tower": ">= 0.4.2",
    "which": ">= 1.0.5"
  },
  "optionalDependencies": {
    "nodemailer": ">= 0.3.28",
    "kue": ">= 0.3.4"
  },
  "devDependencies": {
    "chokidar": "~0.4.0",
    "stylus": ">= 0.29.0",
    "Faker": ">= 0.1.3",
    "less": ">= 1.2.2",
    "uglify-js": ">= 1.1.1",
    "mocha": ">= 0.12.1",
    "chai": ">= 0.3.3",
    "sinon": ">= 1.3.1",
    "knox": ">= 0.0.11",
    "gzip": ">= 0.1.0",
    "cli-table": ">= 0.0.1",
    "grunt-contrib-less": "~0.3.2",
    "grunt-contrib-stylus": "~0.3.1",
    "grunt-contrib": "~0.3.0",
    "superagent": ">= 0.9.5",
    "wrench": ">= 1.3.8",
    "fibers": "~0.6.8",
    "ejs": ">= 0.6.1"
  },
  "scripts": {
    "test": "./node_modules/mocha/bin/mocha $(find test -name \"*Test.coffee\")",
    "prepublish": "npm prune; rm -rf node_modules/*/{test,example,bench}*",
    "start": "node server.js -e production"
  },
  "tower": {
    "stylesheets": "styl",
    "scripts": "coffee",
    "templates": "coffee"
  }
}

Then run

npm install

Next, start your app server

node server

Then, in a second terminal, start the watcher. This will automatically compile files when they change:

cd app
cake watch

Go to localhost:3000 in your browser and you should get something like this expected

cyrilf commented 11 years ago

Thanks @btbinhtran ! You saved me from a headache ;)

pocesar commented 11 years ago

why can't the tasks files be upgraded to version 0.4 of grunt, since it's stable now?

thehydroimpulse commented 11 years ago

@pocesar Because 0.4.0 is quite different than the previous version.

lancejpollard commented 11 years ago

Like @btbinhtran said too, 0.5.0 will be out soon, but if anyone would like to make this work with Grunt 0.4.0, send a pull request. Having this work between now and then would be very helpful. Any questions you have on what to do let us know.