简体   繁体   中英

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

I have successfully run sudo npm install -g karma in addition to installing all the necessary dependencies/preprocessors.

My karma config file can be seen:

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' }
        ]
    }
});

};

The problem appears when I run sudo npm install -g karma-cli I get the error:

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.

What exactly is causing this problem?

It looks like npm wants to delete some files as a step of installing, probably to remove older versions, but it doesn't actually expect it to be there. As a precaution, it appears to be blocking the removal in case the file is associated with something else.

I think if you remove it yourself, or possibly run the install with -f flag to force through the warning you will be fine.

Maybe you or something else installed karma in the past.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM