Cannot use grunt on simple Yeoman angular

北城余情 提交于 2019-12-09 04:22:12

问题


Trying to just startup a simple angular app via Yeoman, using steps in this guide http://www.sitepoint.com/kickstart-your-angularjs-development-with-yeoman-grunt-and-bower/

and get this error when trying to run grunt or grunt server:

Loading "Gruntfile.js" tasks...ERROR
Error: Cannot find module 'load-grunt-tasks'
Warning: Task "default" not found. Use --force to continue.

Here are my versions:

yo --version && grunt --version && bower --version
1.1.2<
grunt-cli v0.1.13
grunt v0.4.4
1.3.1

See screencast of this in action: http://screencast.com/t/4ToPw3SlL2


回答1:


I just encountered the same problem today, managed to resolve it with the answers here.

Basically I needed to update npm to latest version, by using this command (the npm which came with Node-v0.10.29 package was outdated)

npm update npm -g

or

sudo npm update npm -g (i used this command on my mac)

Then type this command

npm --version (it should show 1.5.0-alpha-4 or later version)

Then type the grunt serve command

grunt serve

If you still have issues, then try running these commands

npm install 

or

sudo npm install (i used this command on my mac)

Then try grunt serve command again,

grunt serve

This time, it worked for me.

If it didn't, then try this command

bower install (i did not have to use this command)



回答2:


Run the following commands from the directory that has the Gruntfile.js for your project:

npm install
npm install -g bower
bower install

This will install all npm and bower based dependencies for your project.

In the screencast at 1:18 it shows install errors tied to at least multimatch. load-grunt-taskis dependent on multimatch.




回答3:


Installed "load-grunt-tasks" module locally

ie

npm install load-grunt-tasks

instead of

npm install -g load-grunt-tasks 


来源:https://stackoverflow.com/questions/22734656/cannot-use-grunt-on-simple-yeoman-angular

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!