Ошибка Webpack: Uncaught ReferenceError: требование не определено - PullRequest
1 голос
/ 04 марта 2020

пакет. json

{
  "name": "webpackdemo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "ankit dhoreliya",
  "license": "ISC",
  "dependencies": {
    "@types/requirejs": "^2.1.31",
    "angular-ui-router": "^1.0.25",
    "bootstrap": "^4.4.1"
  },
  "devDependencies": {
    "angular": "^1.7.9",
    "angularjs-template-loader": "^0.1.2",
    "babel-core": "^6.26.3",
    "babel-loader": "^8.0.6",
    "babel-preset-es2015": "^6.24.1",
    "html-loader": "^0.5.5",
    "raw-loader": "^4.0.0",
    "webpack": "^4.42.0",
    "webpack-cli": "^3.3.11"
  }
}

webpack.config. js

let webpack = require('webpack');
module.exports = {
    entry: './app/app.module.js',
    output: {
        path: './bin',
        filename: 'app.bundle.js',
    },
    module: {
        loaders: [
            {
                test: /\.js$/,
                exclude: /node_modules/,
                loader: 'babel-loader',
            },
            { test: /\.html$/, loader: "html" },
            { test: /\.css$/, loader: "style!css" }
        ]
    },
    devtool: "#inline-source-map"
}

приложение. модуль. js Это мой входной файл

angular.module('webpackDemo', []);

require('./home');
require('./login');

Структура проекта enter image description here

Консоль браузера ошибка

app.module.js:3 Uncaught ReferenceError: require is not defined
    at app.module.js:3

Пожалуйста, помогите в этом вопросе и, пожалуйста, скажите мне, как я могу настроить UI-маршрутизацию для моего приложения. Как я могу экспортировать контроллер в индекс. js.

...