我目前正尝试使用 this 从我的 CSS 文件中删除未使用的 CSS .出于某种原因,我不断收到无法解释的错误:
module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
grunt.initConfig({
purifycss: {
options: {
},
target: {
src: ['templates/**/*.html'], // Observe all html files
css: ['static/css/main.css'], // Take all css files into consideration
dest: 'static/css/newcss.css' // Write to this path
}
}
});
grunt.registerTask('default', ['purifycss']);
};
当我在命令行中运行 grunt
时,我得到:
>> TypeError: Cannot read property 'dependencies' of null
Warning: Task "default" not found. Used --force, continuing.
Done, but with warnings.
有人知道为什么会这样吗?
最佳答案
当您的 package.json 丢失并且您正在使用 load-grunt-tasks
时会发生这种情况。运行 npm init
,按照提示进行操作,然后检查生成的依赖项和 devDependencies 是否符合您的预期。
关于javascript - 运行 Grunt 任务返回错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32510524/