Rya*_*ada 364 javascript gruntjs
我首先删除了旧版本的grunt,然后我安装了新的grunt版本,然后我收到了这个错误:
D:\ www\grunt-test\grunt grunt-cli:grunt命令行界面.(v0.1.4)
致命错误:无法找到当地的咕噜声.
如果您看到此消息,则表示未找到Gruntfile或者您的项目未在本地安装grunt.有关安装和配置grunt的更多信息,请参阅"入门指南":http://gruntjs.com/getting-started
这是因为我的系统路径中没有对grunt的引用吗?或者是其他东西?我试过几次重新安装它.
Ans*_*hul 286
我认为你grunt.js
的项目目录中没有文件.使用grunt:init
,它为您提供选项,如jQuery, node,commonjs
.选择你想要的,然后继续.这确实有效.有关更多信息,请访问此页面.
做这个:
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.).
Run Code Online (Sandbox Code Playgroud)
它应该工作.
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.)
Run Code Online (Sandbox Code Playgroud)
编辑:更新了新版本的解决方案:
npm install grunt --save-dev
Run Code Online (Sandbox Code Playgroud)
sup*_*ary 160
Unable to find local Grunt
可能意味着您已在全球范围内安装了Grunt.
Grunt CLI坚持要在本地node_modules目录中安装grunt,因此Grunt是您项目的本地目录.
这将失败:
npm install -g grunt
Run Code Online (Sandbox Code Playgroud)
改为:
npm install grunt --save-dev
Run Code Online (Sandbox Code Playgroud)
Kla*_*urn 82
做
npm install
Run Code Online (Sandbox Code Playgroud)
在本地安装Grunt ./node_modules
(以及package.json
文件中指定的所有其他内容)
Ant*_*ong 25
如果您已package.json
在项目中有一个文件并且它包含grunt
依赖项,
"devDependencies": {
"grunt": "~0.4.0",
Run Code Online (Sandbox Code Playgroud)
然后,您可以运行npm install
以解决此问题
小智 5
我犯了错误,使用sudo和其他没有权限安装一些软件包,这解决了我的问题.
sudo chown -R $(whoami) $HOME/.npm
Run Code Online (Sandbox Code Playgroud)
希望它可以帮到某人.