安装grunt-critical-css时出现问题

时间:2016-04-09 13:54:52

标签: node.js gruntjs

我正在尝试安装

sudo npm install grunt-critical-css --save-dev

Password:**********

我一直在

npm WARN deprecated npmconf@2.0.9: this package has been reintegrated into npm and is now out of date with respect to npm
npm WARN grunt-penthouse@0.3.0 requires a peer of grunt@~0.4.2 but none was installed.

我已经尝试了

sudo npm update -g npm

/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
/usr/local/lib
└── npm@3.8.7 

sudo npm install -g grunt-cli

/usr/local/bin/grunt -> /usr/local/lib/node_modules/grunt-cli/bin/grunt
/usr/local/lib
└── grunt-cli@1.2.0

sudo npm install grunt-critical-css --save-dev

npm WARN deprecated npmconf@2.0.9: this package has been reintegrated into npm and is now out of date with respect to npm
npm WARN grunt-penthouse@0.3.0 requires a peer of grunt@~0.4.2 but none was installed.

我在这里做错了什么?有人可以填写我错过的内容吗?

详细

npm v3.8.7 
grunt-cli v1.2.0
grunt v1.0.1

Gruntfile.js

criticalcss: {
    custom: {
        options: {
            url: "http://localhost:8888",
            width: 1200,
            height: 900,
            outputfile: "public/dist/wedding/css/critical.css",
            filename: "public/dist/wedding/css/all.css",
            buffer: 800*1024,
            ignoreConsole: false
        }
    }
},

加载

grunt.loadNpmTasks('grunt-critical-css');

称之为

 grunt.registerTask('default', [

    'clean:dist',
    'concat',
    'uglify',
    'cssmin',
    // 'htmlmin',
    'compress',
    'criticalcss'

]);

RESULT

咕噜

Warning: Task "criticalcss" not found. Use --force to continue.
Aborted due to warnings.

grunt --force

Warning: Task "criticalcss" not found. Used --force, continuing.
Done, but with warnings.

去检查文件

Nothing generated 

2 个答案:

答案 0 :(得分:4)

这些是警告消息,即使您有这些消息,通常您的scrollView.setSmoothScrollingEnabled(false); 也会成功继续。

这些消息是根据您安装的软件包的所有npm install依赖项注册表以及要安装的软件包的所有层次结构依赖项生成的。

例如,您正在安装的软件包package.json包含此grunt-critical-css https://github.com/filamentgroup/grunt-criticalcss/blob/master/package.json,例如此依赖package.json具有此grunt-cli {{3 ......等等。

在您的情况下,其中一个依赖包(此package.json已被折旧。

答案 1 :(得分:1)

此插件需要Grunt ~0.4.2

看起来您没有安装正确的Grunt版本。 试试这个:

npm update -g npm

sudo npm update -g npm

之后:

npm install -g grunt-cli