在ASP.NET Core 2.0 / Angular模板应用程序上发布失败
发布时间:2020-05-24 22:37:15 所属栏目:asp.Net 来源:互联网
导读:我有一个ASP.NET Core 2.0 / Angular模板应用程序.一切正常,直到我尝试发布. 我收到以下错误: in ./ClientApp/boot.browser.tsModule parse failed: E:rootfolderClientAppboot.browser.ts Unexpected token (14:19)You may need an appropr
|
我有一个ASP.NET Core 2.0 / Angular模板应用程序.一切正常,直到我尝试发布.
in ./ClientApp/boot.browser.ts
Module parse failed: E:rootfolderClientAppboot.browser.ts Unexpected token (14:19)
You may need an appropriate loader to handle this file type.
| const oldRootElem = document.querySelector('app');
| const newRootElem = document.createElement('app');
| oldRootElem!.parentNode!.insertBefore(newRootElem,oldRootElem);
| modulePromise.then(appModule => appModule.destroy());
| });
@ multi event-source-polyfill webpack-hot-middleware/client?path=__webpack_hmr&dynamicPublicPath=true ./ClientApp/boot.browser.ts
到目前为止,我已经完成了通常的谷歌搜索,没有运气.知道我应该在哪里看?这是一个使用VS 2017生成的角度模板的ASP.NET CORE 2.0应用程序.我在下面发布了package.json文件.我得到了相同的结果,我明确地调用了“donet publish”命令或者在VS 2017中按下发布按钮. {
"name": "MyApp","private": true,"version": "0.0.0","scripts": {
"test": "karma start ClientApp/test/karma.conf.js"
},"dependencies": {
"@angular/animations": "^4.4.4","@angular/common": "^4.4.4","@angular/compiler": "^4.4.4","@angular/compiler-cli": "^4.4.4","@angular/core": "^4.4.4","@angular/forms": "^4.4.4","@angular/http": "^4.4.4","@angular/platform-browser": "^4.4.4","@angular/platform-browser-dynamic": "^4.4.4","@angular/platform-server": "^4.4.4","@angular/router": "^4.4.4","@ngtools/webpack": "1.5.0","@types/webpack-env": "1.13.0","angular2-template-loader": "0.6.2","aspnet-prerendering": "^3.0.1","aspnet-webpack": "^2.0.1","awesome-typescript-loader": "3.2.1","bootstrap": "3.3.7","css": "2.2.1","css-loader": "0.28.4","es6-shim": "0.35.3","event-source-polyfill": "0.0.9","expose-loader": "0.7.3","extract-text-webpack-plugin": "2.1.2","file-loader": "0.11.2","html-loader": "0.4.5","isomorphic-fetch": "2.2.1","jquery": "3.2.1","json-loader": "0.5.4","preboot": "4.5.2","raw-loader": "0.5.1","reflect-metadata": "0.1.10","rxjs": "5.4.2","style-loader": "0.18.2","to-string-loader": "1.1.5","typescript": "2.5.0","url-loader": "0.5.9","webpack": "2.5.1","webpack-hot-middleware": "2.18.2","webpack-merge": "4.1.0","zone.js": "0.8.12","angular2-jwt": "^0.2.3"
},"devDependencies": {
"@types/chai": "4.0.1","@types/jasmine": "2.5.53","chai": "4.0.2","jasmine-core": "2.6.4","karma": "1.7.0","karma-chai": "0.1.0","karma-chrome-launcher": "2.2.0","karma-cli": "1.0.1","karma-jasmine": "1.1.0","karma-webpack": "2.0.3"
}
}
WebPack内容如下: const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const AotPlugin = require('@ngtools/webpack').AotPlugin;
const CheckerPlugin = require('awesome-typescript-loader').CheckerPlugin;
module.exports = (env) => {
// Configuration in common to both client-side and server-side bundles
const isDevBuild = !(env && env.prod);
const sharedConfig = {
stats: { modules: false },context: __dirname,resolve: { extensions: [ '.js','.ts' ] },output: {
filename: '[name].js',publicPath: 'dist/' // Webpack dev middleware,if enabled,handles requests for this URL prefix
},module: {
rules: [
//{ test: /.ts$/,include: /ClientApp/,use: isDevBuild ? ['awesome-typescript-loader?silent=true','angular2-template-loader'] : '@ngtools/webpack' },{ test: /.html$/,use: 'html-loader?minimize=false' },{ test: /.css$/,use: [ 'to-string-loader',isDevBuild ? 'css-loader' : 'css-loader?minimize' ] },{ test: /.(png|jpg|jpeg|gif|svg)$/,use: 'url-loader?limit=25000' }
]
},plugins: [new CheckerPlugin()]
};
// Configuration for client-side bundle suitable for running in browsers
const clientBundleOutputDir = './wwwroot/dist';
const clientBundleConfig = merge(sharedConfig,{
entry: { 'main-client': './ClientApp/boot.browser.ts' },output: { path: path.join(__dirname,clientBundleOutputDir) },plugins: [
new webpack.DllReferencePlugin({
context: __dirname,manifest: require('./wwwroot/dist/vendor-manifest.json')
})
].concat(isDevBuild ? [
// Plugins that apply in development builds only
new webpack.SourceMapDevToolPlugin({
filename: '[file].map',// Remove this line if you prefer inline source maps
moduleFilenameTemplate: path.relative(clientBundleOutputDir,'[resourcePath]') // Point sourcemap entries to the original file locations on disk
})
] : [
// Plugins that apply in production builds only
new webpack.optimize.UglifyJsPlugin(),new AotPlugin({
tsConfigPath: './tsconfig.json',entryModule: path.join(__dirname,'ClientApp/app/app.module.browser#AppModule'),exclude: ['./**/*.server.ts']
})
])
});
// Configuration for server-side (prerendering) bundle suitable for running in Node
const serverBundleConfig = merge(sharedConfig,{
resolve: { mainFields: ['main'] },entry: { 'main-server': './ClientApp/boot.server.ts' },manifest: require('./ClientApp/dist/vendor-manifest.json'),sourceType: 'commonjs2',name: './vendor'
})
].concat(isDevBuild ? [] : [
// Plugins that apply in production builds only
new AotPlugin({
tsConfigPath: './tsconfig.json','ClientApp/app/app.module.server#AppModule'),exclude: ['./**/*.browser.ts']
})
]),output: {
libraryTarget: 'commonjs',path: path.join(__dirname,'./ClientApp/dist')
},target: 'node',devtool: 'inline-source-map'
});
return [clientBundleConfig,serverBundleConfig];
};
解决方法通过将我的node / npm版本更新为最新推荐版本来解决此问题. 节点:v8.9.3 npm:5.5.1(编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 升级到.net 4.0后无法加载文件或程序集“AjaxCo
- asp.net-mvc – 在Asp.Net MVC中使用千位分隔符的十进制值
- asp.net-mvc – SportStore:WebUI.WindsorControllerFacto
- asp.net-mvc-3 – MVC将方法添加到jquery.validate.unobtru
- asp.net – 如何获取Page.ClientScript.RegisterClientScri
- asp.net – 为什么aspnet_compiler.exe这么慢(可以做得更快
- ASP.net使用表单将数据插入到sql server表中
- asp.net-mvc-4 – 使用Durandal的会话数据
- asp.net-web-api – System.Web.Routing.RouteCollection不
- 在ASP.NET MVC4中自定义错误消息MVC的无效DateTime
推荐文章
站长推荐
- asp.net – 两次调用HttpModule EndRequest处理程
- 为什么我的IIS7应用程序池在从ASP.NET页面调用的
- asp.net – 谁在生产应用程序中实际使用DataGrid
- ASP.NET Web Forms 4.5模型绑定,其中模型包含一个
- asp.net-mvc – Mvc验证正则表达式只有数字?
- asp.net – AspNetSynchronizationContext
- asp.net – 脚本标记和“%...%”标记之间有什么
- ASP.Net ListView按数据字段分组?
- asp.net-mvc-3 – 如何使用ModelMetadata单元测试
- asp.net-mvc – 嵌套对象的远程ViewModel验证无效
热点阅读
