我刚刚收到了一份grunt软件包的副本,但是我对grunt感到陌生并且很难找到一些事情的答案。最大的问题是不知道下面的错误来自哪里 - 有人能告诉我这是从哪里来的吗?这两个文件都在同一目录中。
$ grunt
>> Local Npm module "grunt-contrib-clean" not found. Is it installed?
>> Local Npm module "grunt-contrib-concat" not found. Is it installed?
>> Local Npm module "grunt-contrib-copy" not found. Is it installed?
>> Local Npm module "grunt-contrib-cssmin" not found. Is it installed?
>> Local Npm module "grunt-contrib-handlebars" not found. Is it installed?
>> Local Npm module "grunt-contrib-jshint" not found. Is it installed?
>> Local Npm module "grunt-contrib-qunit" not found. Is it installed?
>> Local Npm module "grunt-contrib-uglify" not found. Is it installed?
>> Local Npm module "grunt-preprocess" not found. Is it installed?
>> Local Npm module "grunt-wrap" not found. Is it installed?
>> Local Npm module "grunt-debug-task" not found. Is it installed?
Warning: Task "clean" not found. Use --force to continue.
Aborted due to warning.
$
这是我的package.json:
{
"name": "baked-widget",
"srcDirectory": "./src",
"srcJavascript": "./src/js",
"srcCss": "./src/css",
"srcData": "./src/data",
"testDirectory": "./test",
"tgtDirectory": "./build",
"installDirectory": "../com/public/widgets",
"version": "4.2.0",
"devDependencies": {
"grunt": "~0.4",
"grunt-contrib-clean": "~0.4.0",
"grunt-contrib-concat": "~0.3.0",
"grunt-contrib-copy": "~0.5.0",
"grunt-contrib-cssmin": "~0.9.0",
"grunt-contrib-handlebars": "~0.6",
"grunt-contrib-jshint": "~0.8",
"grunt-contrib-uglify": "~0.3",
"grunt-contrib-qunit": "~0.4",
"grunt-contrib-watch": "~0.5",
"grunt-preprocess": "~4.0",
"grunt-wrap": "~0.3",
"grunt-debug-task": "~0.1.4"
}
}
答案 0 :(得分:63)
您可能尚未在本地安装必要的软件包。尝试npm install
(sudo npm install
)以确保您这样做。
答案 1 :(得分:11)
如果接受的答案不起作用并且您有正确的package.json
文件,则可以:
删除node_modules
文件夹(或在某处备份)
然后运行npm install
为了重新开始。
答案 2 :(得分:1)
您必须告诉grunt在哪里可以找到node_modules。我的Gruntfile开头为:
@Value("${system.status.json.filter:oneFilter,anotherOne}")
private String[] filters ;
在我的情况下,node_modules文件夹比Gruntfile高5级(请看setBase方法)。