Skip to content

Error ReferenceError: window is not defined #74

@yankwan

Description

@yankwan

When I run npm run server to start the webpack dev server, it report the error such as below:

Error: E:\js-test\Angularjs-ES6-Demo\src\script\index.html:76
  window.angular.module('ng').run(['$templateCache', function(c) { c.put(path, h  tml) }]);
  ^
  ReferenceError: window is not defined
  
  - index.html:76 Object.
    E:/js-test/Angularjs-ES6-Demo/src/script/index.html:76:1
  
  - index.html:21 __webpack_require__
    E:/js-test/Angularjs-ES6-Demo/src/script/index.html:21:30
  
  - index.html:67 path
    E:/js-test/Angularjs-ES6-Demo/src/script/index.html:67:18
  
  - index.html:70 
    E:/js-test/Angularjs-ES6-Demo/src/script/index.html:70:10
  
  - index.js:231 HtmlWebpackPlugin.evaluateCompilationResult
    [Angularjs-ES6-Demo]/[._html-webpack-plugin@2.30.1@html-webpack-plugin]/inde    x.js:231:26
  
  - index.js:117 
    [Angularjs-ES6-Demo]/[._html-webpack-plugin@2.30.1@html-webpack-plugin]/inde    x.js:117:21
  
  - util.js:16 tryCatcher
    [Angularjs-ES6-Demo]/[._bluebird@3.5.1@bluebird]/js/release/util.js:16:23
  
  - promise.js:512 Promise._settlePromiseFromHandler
    [Angularjs-ES6-Demo]/[._bluebird@3.5.1@bluebird]/js/release/promise.js:512:3    1
  
  - promise.js:569 Promise._settlePromise
    [Angularjs-ES6-Demo]/[._bluebird@3.5.1@bluebird]/js/release/promise.js:569:1    8

I'v been install the html-loader and ngtemplate-loader, and the relative webpack.config.js is:

    module: {
        rules: [
            { 
                test: /\.scss$/, 
                use: ExtractTextPlugin.extract({
                    fallback: "style-loader",
                    use: ["css-loader", 'sass-loader']
                  })
            },// ['style-loader', 'css-loader', 'sass-loader']
            { 
                test: /\.js$/, 
                exclude: /node_modules/, 
                use: ['ng-annotate-loader','babel-loader']
            },
            {
                test: /\.html$/,
                use: [
                    { loader:'ngtemplate-loader?relativeTo=' + (path.resolve(__dirname, './src/')) },
                    { loader: 'html-loader' }
                ]
            }
        ]
    },

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions