Ich migriere die App Angular 1.5 von RquireJS 2.2 zu Webpack 3. Und ich möchte eine Webpack-Umgebung einrichten, die den aktuellen RequireJS-Code unterstützt und schrittweise zu Webpack + ES6 übergeht , Schritt für Schritt, Tests schreiben und den Quellcode refactoring.Modul nicht gefunden: Fehler: 'exports' konnte nicht aufgelöst werden
Jetzt, wenn ich versuche, ein Bündel von webpack
Befehl erzeugen ich die folgende Fehlermeldung erhalten:
[email protected]:~/dev/myapp$ webpack
Hash: 3ac8a9bb3d386514f8a6
Version: webpack 3.4.1
Time: 101ms
Asset Size Chunks Chunk Names
bundle.js 10.7 kB 0 [emitted] main
[0] ./app/bootstrap.js 82 bytes {0} [built]
[2] ./app/app.js 7.37 kB {0} [built]
+ 1 hidden module
ERROR in ./app/app.js
Module not found: Error: Can't resolve 'services/routeResolver' in '/home/trex/dev/myapp/app'
@ ./app/app.js 3:0-175:2
@ ./app/bootstrap.js
ERROR in ./node_modules/angular/index.js
Module not found: Error: Can't resolve 'exports' in '/home/trex/dev/myapp'
@ ./node_modules/angular/index.js 1:0-20
@ ./app/bootstrap.js
Wie kann ich die Ausfuhr in meinem Fall eingestellt?
App Struktur:
[email protected]:~/dev$ tree -L 1 myapp
theapp
├── app
├── css
├── font-awesome
├── fonts
├── img
├── index.html
├── lang
├── lib
├── node_modules
├── package.json
├── README.md
├── resources
├── scripts
├── share
├── templates
├── tests
└── widgets
Einige Bibliotheken sind in node_modules
, andere in lib
Ordner. Alle Bibliotheken direkt in index.html verbunden: <script type="application/javascript" src="lib/angular/angular.min.js" ></script>
Webpack config:
[email protected]:~/dev$ cat myapp/webpack.config.js
var webpack = require('webpack');
var path = require('path');
module.exports = {
entry: "./app/bootstrap.js",
output: {
path: __dirname + '/dist/',
filename: "bundle.js"
},
module: {
loaders: [
{ test: /\.css$/, loader: "style!css" },
{ test: /[\/]angular\.js$/, loader: "exports?angular" }
]
},
resolve: {
alias: {},
extensions: ['.js', '.json'],
modules: [
'node_modules',
'lib'
]
}
};
Stück des Quellcodes:
- myapp/app/app.js https://gist.github.com/sergibondarenko/a87578e774ca43f4fc8a105fa163e13c
- myapp /app/main.js https://gist.github.com/sergibondarenko/9ea25e6ac4f57a7f2703e053efe48ca
- myapp/app/controller/loginController.js https://gist.github.com/sergibondarenko/7c5df871c96f4e9919900f8f87d53a8b
--- UPDATE
ich den Code zu ES6 umgewandelt.
- myapp/app/app.js https://gist.github.com/sergibondarenko/73aa1ba06250c1d347bc44c7b9361c79
- myapp/app/main.js https://gist.github.com/sergibondarenko/ac290eb35f633337edd6ec8d15ccd13b
- myapp/app/controllers/loginController.js https://gist.github.com/sergibondarenko/9c995b4cab2de5d48905bac51c929155
Und jetzt bin habe folgenden Fehler:
[email protected]:~/dev/myapp$ webpack
Hash: 673f49fc25bd759ea99d
Version: webpack 3.4.1
Time: 118ms
Asset Size Chunks Chunk Names
bundle.js 18.2 kB 0 [emitted] main
[1] ./app/bootstrap.js 78 bytes {0} [built]
[2] ./app/app.js 7.35 kB {0} [built]
[3] ./app/services/routeResolver.js 7.07 kB {0} [built]
+ 1 hidden module
ERROR in ./node_modules/angular/index.js
Module not found: Error: Can't resolve 'exports' in '/home/trex/dev/myspp'
@ ./node_modules/angular/index.js 1:0-20
@ ./app/bootstrap.js
können Sie bootstrap.js liefern und ./node_modules/angular/index.js Dateien? Was genau ist die angulare Version bei node_modules? –