概述
本文翻译自:What is causing this error - “Fatal error: Unable to find local grunt”
I removed the old version of grunt first, then I installed the new grunt version, and then I got this error: 我首先删除了旧版本的grunt,然后我安装了新的grunt版本,然后我收到了这个错误:
D:\www\grunt-test\grunt grunt-cli: The grunt command line interface. D:\ www \ grunt-test \ grunt grunt-cli:grunt命令行界面。 (v0.1.4) (v0.1.4)
Fatal error: Unable to find local grunt. 致命错误:无法找到当地的咕噜声。
If you're seeing this message, either a Gruntfile wasn't found or grunt hasn't been installed locally to your project. 如果您看到此消息,则表示未找到Gruntfile或者您的项目未在本地安装grunt。 For more information about installing and configuring grunt, please see the Getting Started guide: http://gruntjs.com/getting-started 有关安装和配置grunt的更多信息,请参阅“入门指南”: http : //gruntjs.com/getting-started
Is this because there is not a reference to grunt in my system path? 这是因为我的系统路径中没有对grunt的引用吗? Or something else? 或者是其他东西? I tried to re-install it a few times already. 我试过几次重新安装它。
#1楼
参考:https://stackoom.com/question/wQlY/导致此错误的原因是什么-致命错误-无法找到本地咕噜声
#2楼
I think you don't have a grunt.js
file in your project directory. 我认为你的项目目录中没有grunt.js
文件。 Use grunt:init
, which gives you options such as jQuery, node,commonjs
. 使用grunt:init
,它为您提供jQuery, node,commonjs
等选项。 Select what you want, then proceed. 选择你想要的,然后继续。 This really works. 这确实有效。 For more information you can visit this . 有关更多信息,请访问此页面 。
Do 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.).
It should work. 它应该工作。
Solution for v1.4: 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.)
Edit : Updated solution for new versions: 编辑:更新了新版本的解决方案:
npm install grunt --save-dev
#3楼
Install Grunt in node_modules rather than globally 在node_modules中安装Grunt而不是全局安装
Unable to find local Grunt
likely means that you have installed Grunt globally. Unable to find local Grunt
可能意味着您已在全球范围内安装了Grunt。
The Grunt CLI insists that you install grunt in your local node_modules directory, so Grunt is local to your project. Grunt CLI坚持要在本地node_modules目录中安装grunt,因此Grunt是您项目的本地目录。
This will fail: 这将失败:
npm install -g grunt
Do this instead: 改为:
npm install grunt --save-dev
#4楼
If you already have a file package.json
in the project and it contains grunt
in dependency, 如果你在项目中已经有一个文件package.json
,它包含依赖的grunt
,
"devDependencies": {
"grunt": "~0.4.0",
Then you can run npm install
to resolve the issue 然后你可以运行npm install
来解决这个问题
#5楼
Do 做
npm install
to install Grunt locally in ./node_modules
(and everything else specified in the package.json
file) 在./node_modules
本地安装Grunt(以及package.json
文件中指定的所有其他内容)
#6楼
Could be a few problems here depending on what version of grunt is being used. 这可能是一些问题,具体取决于使用的grunt版本。 Newer versions of grunt actually specify that you have a file named Gruntfile.js
(instead of the old grunt.js
). 较新版本的grunt实际上指定您有一个名为Gruntfile.js
的文件(而不是旧的grunt.js
)。
You should have the grunt-cli
tool be installed globally (this is done via npm install -g grunt-cli
). 您应该全局安装grunt-cli
工具(这可以通过npm install -g grunt-cli
)。 This allows you to actually run grunt
commands from the command line. 这允许您从命令行实际运行grunt
命令。
Secondly make sure you've installed grunt locally for your project. 其次,请确保您已在本地为您的项目安装了grunt。 If you see your package.json
doesn't have something like "grunt": "0.4.5"
in it then you should do npm install grunt --save
in your project directory. 如果你看到你的package.json
没有类似"grunt": "0.4.5"
的东西那么你应该在项目目录中执行npm install grunt --save
。
最后
以上就是迷人学姐为你收集整理的导致此错误的原因是什么 - “致命错误:无法找到本地咕噜声”的全部内容,希望文章能够帮你解决导致此错误的原因是什么 - “致命错误:无法找到本地咕噜声”所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复