当前位置: 代码迷 >> Ruby/Rails >> grunt异常——Fatal error: Unable to find Gruntfile
  详细解决方案

grunt异常——Fatal error: Unable to find Gruntfile

热度:293   发布时间:2016-04-29 02:13:14.0
grunt错误——Fatal error: Unable to find Gruntfile
E:\website\jquery-plugins>gruntA valid Gruntfile could not be found. Please see the getting started guide formore information on how to configure grunt: http://gruntjs.com/getting-startedFatal error: Unable to find Gruntfile.

错误提示Gruntfile.js文件找不到,但项目中已经有Gruntfile.js文件,后来发现是用npm安装grunt模块时,没有安装完整(可能是中途中断了安装,但grunt模块的目录已经存在与node_modules目录下),解决办法是重新安装grunt模块:

E:\website\jquery-plugins>npm install grunt

再次执行:

E:\website\jquery-plugins> gruntLoading "uglify.js" tasks...ERROR>> Error: ENOENT, no such file or directory 'E:\website\jquery-plugins\node_modules\grunt-contrib-uglify\node_modules\uglify-js\lib\utils.src'Warning: Task "uglify" not found. Use --force to continue.Aborted due to warnings.

错误提示没有这个文件或者目录,猜测gruntuglify插件也没有安装完整,重新安装:

E:\website\jquery-plugins>npm install grunt-contrib-uglify --save-dev

执行grunt的默认tasks(我这里的默认tasks只有uglify

E:\website\jquery-plugins>gruntRunning "uglify:build" (uglify) task>> 1 file created.Done, without errors.
  相关解决方案