Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught Error: Module name "http-errors" #105

Open
Ratikant01 opened this issue Apr 26, 2018 · 0 comments
Open

Uncaught Error: Module name "http-errors" #105

Ratikant01 opened this issue Apr 26, 2018 · 0 comments

Comments

@Ratikant01
Copy link

Hi,

I am using karma-requirejs for testing Node-Express project. But I am getting below error when doing npm test. Can anyone help me on this?

{ "message": "Uncaught Error: Module name \"http-errors\" has not been loaded yet for context: _. Use require([])\nhttp://requirejs.org/docs/errors.html#notloaded\nat node_modules/requirejs/require.js:143:9\n\nError: Module name \"http-errors\" has not been loaded yet for context: _. Use require([])\nhttp://requirejs.org/docs/errors.html#notloaded\n at makeError (node_modules/requirejs/require.js:168:17)\n at Object.localRequire [as require] (node_modules/requirejs/require.js:1436:44)\n at requirejs (node_modules/requirejs/require.js:1797:24)\n at app.js:1:19", "str": "Uncaught Error: Module name \"http-errors\" has not been loaded yet for context: _. Use require([])\nhttp://requirejs.org/docs/errors.html#notloaded\nat node_modules/requirejs/require.js:143:9\n\nError: Module name \"http-errors\" has not been loaded yet for context: _. Use require([])\nhttp://requirejs.org/docs/errors.html#notloaded\n at makeError (node_modules/requirejs/require.js:168:17)\n at Object.localRequire [as require] (node_modules/requirejs/require.js:1436:44)\n at requirejs (node_modules/requirejs/require.js:1797:24)\n at app.js:1:19" }

package.json
"scripts": { "start": "node ./bin/www", "test": "karma start & karma run" }, "dependencies": { "browserify": "^16.2.0", "cookie-parser": "~1.4.3", "debug": "~2.6.9", "express": "~4.16.0", "http-errors": "^1.6.3", "jade": "~1.11.0", "morgan": "~1.9.0", "mysql": "^2.15.0", "sqlite3": "^4.0.0", "watchify": "^3.11.0" }, "devDependencies": { "jasmine-core": "~2.8.0", "jasmine-spec-reporter": "~4.2.1", "karma": "^2.0.2", "karma-browserify": "^5.2.0", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "^1.2.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "karma-phantomjs-launcher": "^1.0.4", "karma-requirejs": "^1.1.0", "karma-webpack": "^3.0.0", "requirejs": "^2.3.5", "webpack": "^4.6.0", "webpack-node-externals": "^1.7.2" }

karma.conf.js
`// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html

const nodeExternals = require('webpack-node-externals');

module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', 'requirejs'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
//require('karma-phantomjs-launcher'),
//require('karma-jasmine-html-reporter'),
//require('karma-coverage-istanbul-reporter'),
require('karma-requirejs')
],
files: [
'test-main.js',
'app.js',
{pattern: 'routes/.js', included: false},
{pattern: 'spec/
.spec.js', included: false},

    ],
    preprocessors: {
        //use webpack to support require() in test-suits .js files
        //use babel-loader from webpack to compile es2015 features in .js files
        //add webpack as preprocessor
        // 'app.js': ['webpack'],
        // 'routes/*.js': ['webpack'],
        // 'spec/*.spec.js': ['webpack']
    },
    client: {
        clearContext: false
    },
    // reporters: ['progress', 'coverage-istanbul', 'kjhtml'],
    reporters: ['dots'],
    coverageIstanbulReporter: {
        reports: ['html', 'text-summary'],
        fixWebpackSourcePaths: true
    },
    /*webpack: {
        target: 'node',
        node: {
            fs: 'empty'
        },
        mode: 'development',
        externals: [nodeExternals()]
    },*/
    port: 9876,
    colors: true,
    logLevel: config.LOG_INFO,
    autoWatch: true,
    browsers: ['Chrome'],
    singleRun: false
});

};`

@Ratikant01 Ratikant01 changed the title Uncaught Error: Module name "http-errors Uncaught Error: Module name "http-errors" Apr 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant