npm -g install karma-cli 给出错误 (Karma/AngularJS)

npm -g install karma-cli gives error (Karma/AngularJS)

我已经成功 运行 sudo npm install -g karma 除了安装所有必要的 dependencies/preprocessors。

可以看到我的karma配置文件:

module.exports = function(config) {
config.set({
    rootElement: '#receiveQuote',
    browsers: ['PhantomJS'],
    frameworks: [
        'jasmine',
        'phantomjs-shim',
        'fixture'
    ],
    captureTimeout: 60000,
    reportSlowerThan: 1500,
    reporters: [
        'progress',
        'coverage'
    ],
    preprocessors: {
        '**/*.html': 'ng-html2js',
        '../app/**/*.html': 'ng-html2js',
        '**/*.json': 'json_fixtures',
        '../app/**/*.js': [
            'coverage'
        ]
    },
    files: [
        // bootstrap/dependencies
        '../vendor/assets/bower_components/jQuery/dist/jquery.min.js',
        '../vendor/assets/bower_components/lodash/lodash.min.js',
        '../app/assets/javascripts/application.js',
        '../app/assets/javascripts/bootstrap.min.js',
        '../vendor/assets/bower_components/angular/angular.js',
        '../vendor/assets/bower_components/angular-mocks/angular-mocks.js',
        '../vendor/assets/bower_components/angular-animate/angular-animate.js',
        '../vendor/assets/bower_components/angular-route/angular-route.js',
        '../vendor/assets/bower_components/angular-touch/angular-touch.js',
        '../vendor/assets/bower_components/angular-translate/angular-translate.js',
        '../vendor/assets/bower_components/ng-token-auth/dist/ng-token-auth.js',
        '../vendor/assets/bower_components/angular-messages/angular-messages.js',
        '../vendor/assets/bower_components/messageformat/messageformat.js',
        '../vendor/assets/bower_components/angular-translate-interpolation-messageformat/angular-translate-interpolation-messageformat.js',
        '../vendor/assets/bower_components/angular-aria/angular-aria.js',
        '../vendor/assets/bower_components/angular-placeholder-tai/lib/tai-placeholder.js',
        '../vendor/assets/bower_components/angular-sanitize/angular-sanitize.js',
        '../vendor/assets/bower_components/angular-bootstrap/ui-bootstrap-tpls.js',
        '../vendor/assets/bower_components/angular-ui-mask/dist/mask.js',
        '../vendor/assets/bower_components/moment/moment.js',
        '../vendor/assets/bower_components/sinonjs/sinon.js',
        '../vendor/assets/bower_components/angular-cookie/angular-cookie.js',
        // app src files
        '../app/assets/javascripts/main.js',
        '../app/assets/javascripts/**/*.js',
        //templates
        '../app/**/*.html',
        //test templates
        'tests/**/*.html',
        'tests/fixtures/**/*.json',
        //test files
        'spec_helper.js',
        'tests/**/*.js'
    ],
    exclude: [
        '../app/assets/javascripts/qe/**/*.js'
    ],
    ngHtml2JsPreprocessor: {
        stripPrefix: '.*app/assets/javascripts/'
    },
    jsonFixturesPreprocessor: {
        variableName: '__json__'
    },
    coverageReporter: {
        dir : 'coverage/',
        reporters: [
            { type: 'html', subdir: 'html' },
            { type: 'text', subdir: '.', file: 'report.txt' }
        ]
    }
});

};

当我 运行 sudo npm install -g karma-cli 时出现问题 我得到错误:

Refusing to delete: /usr/bin/karma not in /usr/lib/node_modules/karma-cli  File exists: /usr/bin/karma
Move it away, and try again.

究竟是什么导致了这个问题?

看起来 npm 想要删除一些文件作为安装的一个步骤,可能是为了删除旧版本,但它实际上并不希望它在那里。作为预防措施,如果文件与其他文件相关联,它似乎会阻止删除。

我认为如果您自己将其删除,或者可能 运行 使用 -f 标志进行安装以强制通过警告,您会没事的。

也许您或其他人过去安装了业力。