Closed zation closed 11 years ago
As stated in the readme file, grunt-bower
assumes you have bower
installed globally.
Try npm install -g bower
and see if it works.
Personally, I want to handle the package management by command line, so a global installed bower
is needed.
If you prefer a more streamlined workflow, take a look at grunt-bower-task.
FYI I tried and install of bower
globally wont be enough it has to be installed locally npm install bower
which is something I would like to avoid.
@nrako can you be more specific on your setup? grunt
version, bower
version etc.
Latest version for everything, but I don't think the problem rely on the version at least if you use npm > 1.0.0. Check this link http://blog.nodejs.org/2011/03/23/npm-1-0-global-vs-local-installation/
I tried several setups, grunt
0.3.7 or 0.4.0, always globally installed bower
.
Never have any issue you mentioned.
I'm really trying to tackle this down, but have no idea what's can be wrong here.
Do you need privilege to install bower
globally? Something like sudo npm install -g bower
?
Do you have $NODE_PATH
correctly set?
Ah! Okay of course now I understand, you probably have the global node_modules directory in your NODE_PATH
.
If you try require.resolve('bower')
it probably show up bower from your NODE_PATH
.
My NODE_PATH
is setup correctly which is empty. NODE_PATH
exists mostly for legacy reason and it's highly discouraged to use it. There are many reasons for that, what happening now is one of them.
From nodejs.org
These are mostly for historic reasons. You are highly encouraged to place your dependencies locally in node_modules folders. They will be loaded faster, and more reliably.
I'm not aware of that NODE_PATH
is a legacy environment variable, good to learn that!!
Just unset my NODE_PATH
and use npm config set prefix MY_NODE_MODULE_PATH
, everything work just fine.
But, I can't really see how this is related how you require
a globally installed package.
If setup correctly, no matter via $prefix
or $NODE_PATH
, require('some_package')
should just works.
No It shouldn't global package are for CLI. If a package is used both as a cli and a local package require()
it must be installed both globally and locally, or maybe use npm link
(but I wouldn't except for rare case). I learnt something too with npm config set prefix
I don't really understand how it solve this but if I were you, I wouldn't change anything, you shouldn't have to.
npm folder — ref first bullet point list.
Maybe you think it is a bit anti-DRY but that just the way npm works, all dependencies of your package should be listed in your package.json.
BTW Grunt adopted an elegant solution to do that (among others) with grunt-cli
(-g) and grunt
local package where grunt-cli
is only a cli interface for the local grunt
package, maybe bower will come to that in the future.
Just added bower
as dependency to package.json
.
Thanks for your time sharing this, much appreciated.
I've install grunt-bower and config my
Gruntfile.js
as below:but when I run
grunt
, I gotError: Cannot find module 'bower'
. And I checked the package.json of grunt-bower, I noticed the bower is in devDependencies. Can you put it into dependencies?