在ASP.NET Core 2.0 / Angular模板应用程序上发布失败
发布时间:2020-12-15 19:52:55 所属栏目: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 appropriate loader
我有一个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-mvc – MVC 5实体框架6执行存储过程
- asp.net – 在构造函数asp net中访问WebControls可标记的属
- 优化 – MVC4捆绑策略
- ASP.NET MVC3(Razor)中的视图中局部变量的简单增量
- ASP.NET MVC5+EF6+EasyUI 后台管理系统(65)-MVC WebApi 用
- asp.net – 动态设置超链接控件的navigationurl属性内联
- asp.net-mvc-3 – MVC 3 $.ajax – 响应似乎是从部分视图缓
- asp.net-mvc – 将HTML.EditorFor转换为下拉列表(html.drop
- asp.net – 使用Visual Studio中的查询字符串参数进行调试
- asp.net – 如何使用多个项目部署单个解决方案?
推荐文章
站长推荐
- asp.net-mvc-3 – MVC3 Html.EditorFor在我的视图
- asp.net-mvc – ASP.NET MVC表单身份验证和未经身
- asp.net – 它是老式的使用id的查询字符串吗?
- 利用ASP.NET SiteMap生成与Bootstrap"兼容&#
- asp.net-mvc – 如何在共享托管环境中实现ASP.Ne
- asp.net-mvc – 我的MVC 5模板中没有Application
- asp.net – 如何添加.aspx页面到现有的MVC 4项目
- asp.net-mvc-5 – 在GenerateUserIdentityAsync方
- asp.net – 添加新行到datatable的顶部
- .net – MVC3与EF 4.1和EntityState.Modified更新
热点阅读