typeorm: Error with 'createConnection' building with Webpack and Jasmine

Hello,

Whenever I call the createConnection() function inside my test file I get the following error:

ERROR in ./~/app-root-path/lib/resolve.js
Module not found: Error: Cannot resolve module 'module' in /Users/profile/Documents/node_modules/app-root-path/lib
 @ ./~/app-root-path/lib/resolve.js 7:18-35

with a bunch of warnings that look like the following:

WARNING in ./~/app-root-path/lib/resolve.js
Critical dependencies:
31:15-32 the request of a dependency is an expression
 @ ./~/app-root-path/lib/resolve.js 31:15-32

Here’s my current webpack configuration:

var path = require('path');
var webpack = require('webpack');

module.exports =
{
    entry : {
        bundle: [ 'webpack-hot-middleware/client?timeout=20000&reload=true', './src/client/client.tsx' ],
        test:   [ 'webpack-hot-middleware/client?timeout=20000&reload=true', './specRoot.js' ]
    },
    output :
    {
        publicPath : '/',
        path: path.join(__dirname, '/public/'),
        filename : '[name].js',
        hotUpdateChunkFilename: 'hot/[id].[hash].hot-update.js',
        hotUpdateMainFilename: 'hot/[hash].hot-update.json',
        devtoolModuleFilenameTemplate: function(info) {
            return "file:///"+encodeURI(info.absoluteResourcePath);
        }
    },
    plugins : [
        new webpack.optimize.OccurenceOrderPlugin(),
        new webpack.HotModuleReplacementPlugin(),
        new webpack.NoErrorsPlugin()
    ],
    devtool : "source-map",
    resolve:
    {
        // Add '.ts' and '.tsx' as resolvable extensions.
        extensions: ["", ".webpack.js", ".web.js", ".ts", ".tsx", ".js"]
    },
    module :
    {
        loaders :
        [
            { test : /\.tsx?$/, loaders : [ 'ts-loader'] },
            { test: /\.js$/, exclude: [/node_modules/, /Documentation/], loaders: [ 'react-hot-loader/webpack' ] }
        ]
    },
    externals:
    {
        "react": "React",
        "react-dom": "ReactDOM",
        'jsdom': 'window',
        'cheerio': 'window',
        'react/addons': true,
        'react/lib/ExecutionEnvironment': true,
        'react/lib/ReactContext': true
    },
    node: {
        fs: "empty",
        tls: "empty",
        net: "empty"
    }
};

Here is me calling the createConnection method inside my test file:

it ('testing connection', () =>
    {
        // jasmine.createSpy('testSpy', createConnection).and.callThrough();
        createConnection();
    });

Do you know what I can do to resolve this issue?

Ps. I’m using the latest version.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

I guess we can close it. @19majkel94 thank you for help!