导致此错误的原因 - “致命错误:无法找到本地 grunt”

2023-12-04

我先删除了旧版本的 grunt,然后安装了新的 grunt 版本,然后出现了这个错误:

D:\www\grunt-test\grunt grunt-cli:grunt 命令行界面。 (v0.1.4)

致命错误:无法找到本地 grunt。

如果您看到此消息,则可能是未找到 Gruntfile,或者 grunt 尚未安装到您的项目本地。了解更多 有关安装和配置 grunt 的信息,请参阅 入门指南:http://gruntjs.com/getting-started

这是因为我的系统路径中没有对 grunt 的引用吗?或者是其他东西?我已经尝试重新安装几次了。


我认为你没有grunt.js文件位于您的项目目录中。使用grunt:init,它为您提供了诸如jQuery, node,commonjs。选择您想要的内容,然后继续。这确实有效。欲了解更多信息,您可以访问this.

做这个:

 1. npm install -g grunt
 2. grunt:init  ( you will get following options ):
      jquery: A jQuery plugin
      node: A Node module
      commonjs: A CommonJS module
      gruntplugin: A Grunt plugin
      gruntfile: A Gruntfile (grunt.js)
 3 .grunt init:jquery (if you want to create a jQuery related project.).

它应该有效。

v1.4的解决方案:

1. npm install -g grunt-cli
2. npm init
   fill all details and it will create a package.json file.
3. npm install grunt (for grunt dependencies.)

编辑:新版本的更新解决方案:

 npm install grunt --save-dev
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

导致此错误的原因 - “致命错误:无法找到本地 grunt” 的相关文章

随机推荐