首页 > 解决方案 > “警告:“路径”参数必须是字符串类型使用 --force 继续。”

问题描述

当我尝试在新的开发安装上运行 grunt 时收到此错误:

"Warning: The "path" argument must be of type string Use --force to continue."

这是我的gruntfile.js样子。我已经排除了不正确的路径,还有什么可能导致这种情况以及如何确定坏路径的位置?

module.exports = function (grunt) {
'use strict';

// Load all grunt tasks
require( 'matchdep' ).filterDev( 'grunt-*' ).forEach( grunt.loadNpmTasks );

// Project configuration
grunt.initConfig( {
    pkg   : grunt.file.readJSON( 'package.json' ),
    concat: {
        options     : {
            stripBanners: true,
            banner      : '/*! <%= pkg.title %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
                ' * <%= pkg.homepage %>\n' +
                ' * Copyright (c) <%= grunt.template.today("yyyy") %>;' +
                ' * Licensed GPLv2+' +
                ' */\n'
        },
        jdrf_promise: {
            src : [
                'assets/js/src/jdrf_promise.js',
                'assets/js/src/promise_map.js'
            ],
            dest: 'assets/js/jdrf_promise.js'
        }
    },
    jshint: {
        browser: {
            options: {
                jshintrc: '.jshintrc',
                reporter: require( 'jshint-stylish' )
            },
            src    : [
                'assets/js/src/*.js'
            ]

        }
    },
    uglify: {
        all: {
            files  : {
                'assets/js/jdrf_promise.min.js': ['assets/js/jdrf_promise.js'],
                'assets/js/promise_map.min.js' : ['assets/js/promise_map.js']
            },
            options: {
                banner    : '/*! <%= pkg.title %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
                    ' * <%= pkg.homepage %>\n' +
                    ' * Copyright (c) <%= grunt.template.today("yyyy") %>;' +
                    ' * Licensed GPLv2+' +
                    ' */\n',
                mangle    : false,
                beautify  : false,
                semicolons: true
            }
        }
    },
    test  : {
        files: ['assets/js/test/**/*.js']
    },
    compass: {
        dev: {
            options: {
                sassDir    : ['assets/css/sass'],
                cssDir     : ['assets/css'],
                environment: 'development',
                outputStyle: 'expanded'
            }
        },
        dist: {
            options: {
                sassDir: 'assets/css/sass',
                cssDir : 'assets/css/'
            }
        }
    },
    cssmin : {
        options: {
            banner: '/*! <%= pkg.title %> - v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
                ' * <%= pkg.homepage %>\n' +
                ' * Copyright (c) <%= grunt.template.today("yyyy") %>;' +
                ' * Licensed GPLv2+' +
                ' */\n'
        },
        minify : {
            expand: true,

            cwd: 'assets/css',
            src: ['jdrf_promise.css'],

            dest: 'assets/css',
            ext : '.min.css'
        }
    },
    watch  : {
        compass: {
            files: ['assets/css/sass/*.scss', 'assets/css/sass/*/*.scss'],
            tasks: ['compass:dev']
        },
        styles: {
            files: ['assets/css/jdrf_promise.css'],
            tasks: ['cssmin']
        },
        scripts: {
            files  : ['assets/js/src/**/*.js', 'assets/js/vendor/**/*.js'],
            tasks  : ['jshint', 'concat', 'uglify'],
            options: {
                debounceDelay: 500
            }
        }
    }
} );

//Dependent plugins
grunt.loadNpmTasks( 'grunt-contrib-compass' );
grunt.loadNpmTasks( 'grunt-contrib-watch' );

// Default task.,
grunt.registerTask( 'default', ['jshint', 'concat', 'uglify', 'compass:dev', 'cssmin' ] );

grunt.util.linefeed = '\n';
};

标签: npmgruntjs

解决方案


推荐阅读