[英]angular2-template-loader: Error: Can't resolve './' in \@angular\compiler\src
Trying to bundle my angular2 app with webpack2 and angular2-template-loader, but getting this error: 尝试将我的angular2应用程序与webpack2和angular2-template-loader捆绑在一起,但出现此错误:
ERROR in ./~/@angular/compiler/src/compile_metadata.js
Module not found: Error: Can't resolve './' in 'C:\Users\eagor\Documents\work\node_modules\@angular\compiler\src'
@ ./~/@angular/compiler/src/compile_metadata.js 393:22-35
@ ./~/@angular/compiler/index.js
@ ./~/@angular/platform-browser-dynamic/src/platform-browser-dynamic.js
@ ./~/@angular/platform-browser-dynamic/index.js
@ ./src/login/index.js
Without the angular2-template-loader
it bunldes just fine. 如果没有
angular2-template-loader
它会捆绑在一起。
src/login/index.js: SRC /登录/ index.js:
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { LoginModule } from './src/login.module';
document.addEventListener('DOMContentLoaded', function() {
platformBrowserDynamic()
.bootstrapModule(LoginModule);
});
src/login/src/login.module.js SRC /登录/ SRC / login.module.js
export class LoginModule {
// make empty for example.
}
webpack.config.js: webpack.config.js:
var path = require("path");
module.exports = {
entry: {
login: "./src/login/index.js"
},
output: {
path: path.resolve(__dirname, "wwwroot/bundles"),
filename: "[name].min.js"
},
module: {
loaders: [
{
test: /\.js$/, exclude: /node_modules/,
loader: "babel-loader"
},
// adding this loader breaks
{
test: /\.js$/,
loaders: ['angular2-template-loader'],
exclude: [/\.(spec)\.js$/]
},
{
test: /\.(html|css)$/,
loader: 'raw-loader'
}
]
}
};
You should exclude the node_modules
folder: 您应该排除
node_modules
文件夹:
{
test: /\.js$/,
loaders: ['angular2-template-loader'],
exclude: [/node_modules/, /\.(spec)\.js$/]
}
Otherwise webpack tries to pipe also .js
files that are located somewhere in the node_modules
folder through your pipeline, which is something you don't want and breaks things in your case. 否则的WebPack试图管也
.js
,它们位于某处的文件node_modules
夹通过你的管道,这是你不想要的东西,你的情况打破东西。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.