我在问这里之前已经阅读了很多不同的帖子但是我无法解决这个错误"找不到Uglify" ..
我已经下载了node.js,uglfy.js ..很快我就按照这里的所有步骤进行了操作.. How to install grunt and how to build script with it
我的Gruntjs文件:
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
build: {
src: 'js/global.js',
dest: 'js/build/global.min.js'
}
}
});
// Load the plugin that provides the "uglify" task.
grunt.loadNpmTasks('grunt-contrib-uglify');
// Default task(s).
grunt.registerTask('default', ['uglify']);
};
和package.json:
{
"name": "contentImageSlider",
"version": "0.1.0",
"devDependencies": {
"grunt": "^0.4.5",
"grunt-contrib-concat": "^0.4.0",
"grunt-contrib-jshint": "~0.10.0",
"grunt-contrib-nodeunit": "~0.3.3",
"grunt-contrib-uglify": "~0.4.0"
},
"description": "slider",
"main": "Gruntfile.js",
"dependencies": {
"grunt": "^0.4.5"
},
"scripts": {
"test": "test"
},
"repository": {
"type": "git",
"url": "https://github.com/haldunatar/contentImageSlider.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/haldunatar/contentImageSlider/issues"
},
"homepage": "https://github.com/haldunatar/contentImageSlider"
}
错误:
Local Npm module "grunt-contrib-uglify" not found. is it installed?
Warning:Tast 'uglify' not found. use --force to continue.
Aborted due to warnings.
因此每当我进入" grunt"时,它就会出现错误..但我下载了uglify.js ..
有人可以帮助我吗?
提前致谢!
答案 0 :(得分:1)
我看到" grunt-contrib-uglify"在您的package.json
文件中,但错误表明它未安装。也许您最近添加了依赖项但没有执行npm install
?尝试从根目录运行npm install
,然后重新运行grunt
。