aspnetcore-angular-universal icon indicating copy to clipboard operation
aspnetcore-angular-universal copied to clipboard

Prod build failed

Open mykvas opened this issue 9 years ago • 46 comments

step to reproduce download the project from branch "master" npm install npm run build:prod has the next bug image

the regexp should be as this one image

how can i skip minimization for current regexp?

mykvas avatar Nov 04 '17 18:11 mykvas

I have the same problem when deploying the latest starter (Angular 5) to my web hosting provider (the previous Angular 4 version runs OK in the same server).

See: "...Prerendering failed because of error: SyntaxError: Invalid regular expression: /^[_A-Za- ... ". Including error and part of the stack trace below:

        Hosting environment: Production
        Content root path: C:\ClientSites\aztectechnologies.net\paroissesaintremi.online
        Now listening on: http://localhost:27973
        Application started. Press Ctrl+C to shut down.
        info: Microsoft.AspNetCore.Hosting.Internal.WebHost[1]

            at Object.create.location.get (C:\ClientSites\aztectechnologies.net\paroissesaintremi.online\ClientApp\dist\main-server.js:1542:16379)
            at __webpack_require__ (C:\ClientSites\aztectechnologies.net\paroissesaintremi.online\ClientApp\dist\main-server.js:1:355)
            at Object.<anonymous> (C:\ClientSites\aztectechnologies.net\paroissesaintremi.online\ClientApp\dist\main-server.js:1030:27089)
            at __webpack_require__ (C:\ClientSites\aztectechnologies.net\paroissesaintremi.online\ClientApp\dist\main-server.js:1:355)
            at Object.exports.isValidName (C:\ClientSites\aztectechnologies.net\paroissesaintremi.online\ClientApp\dist\main-server.js:1542:2523)
            at __webpack_require__ (C:\ClientSites\aztectechnologies.net\paroissesaintremi.online\ClientApp\dist\main-server.js:1:355)
            at Object.module.exports (C:\ClientSites\aztectechnologies.net\paroissesaintremi.online\ClientApp\dist\main-server.js:1091:2699)
            at __webpack_require__ (C:\ClientSites\aztectechnologies.net\paroissesaintremi.online\ClientApp\dist\main-server.js:1:355)
            at Object.module.exports (C:\ClientSites\aztectechnologies.net\paroissesaintremi.online\ClientApp\dist\main-server.js:1939:412)
        Current directory is: C:\ClientSites\aztectechnologies.net\paroissesaintremi.online

        at Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance.<InvokeExportAsync>d__7`1.MoveNext()
        --- End of stack trace from previous location where exception was thrown ---
        at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
        at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)      Request starting HTTP/1.1 GET http://paroissesaintremi.online/  
        info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[1]
            Executing action method AspCoreServer.Controllers.HomeController.Index (Asp2017) with arguments ((null)) - ModelState is Valid
        info: Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker[2]
            Executed action AspCoreServer.Controllers.HomeController.Index (Asp2017) in 1924.9405ms
        fail: Microsoft.AspNetCore.Server.Kestrel[13]
            Connection id "0HL941CASFAVL", Request id "0HL941CASFAVL:00000001": An unhandled exception was thrown by the application.
        Microsoft.AspNetCore.NodeServices.HostingModels.NodeInvocationException: Prerendering failed because of error: SyntaxError: Invalid regular expression: /^[_A-Za-zA-�O-�o-??-??-??-?�-??-??-??-??-??-??-?:][-._A-Za-z0-9�A-�O-�o-?`-??-?????�-??-??-??-??-??-??-?:]*$/: Range out of order in character class
            at RegExp (native)
            at Object.create.location.get (C:\ClientSites\aztectechnologies.net\paroissesaintremi.online\ClientApp\dist\main-server.js:1542:16379)
            at __webpack_require__ (C:\ClientSites\aztectechnologies.net\paroissesaintremi.online\ClientApp\dist\main-server.js:1:355)
            at Object.<anonymous> (C:\ClientSites\aztectechnologies.net\paroissesaintremi.online\ClientApp\dist\main-server.js:1030:27089)
            at __webpack_require__ (C:\ClientSites\aztectechnologies.net\paroissesaintremi.online\ClientApp\dist\main-server.js:1:355)
            at Object.exports.isValidName (C:\ClientSites\aztectechnologies.net\paroissesaintremi.online\ClientApp\dist\main-server.js:1542:2523)
            at __webpack_require__ (C:\ClientSites\aztectechnologies.net\paroissesaintremi.online\ClientApp\dist\main-server.js:1:355)
            at Object.module.exports (C:\ClientSites\aztectechnologies.net\paroissesaintremi.online\ClientApp\dist\main-server.js:1091:2699)
            at __webpack_require__ (C:\ClientSites\aztectechnologies.net\paroissesaintremi.online\ClientApp\dist\main-server.js:1:355)
            at Object.module.exports (C:\ClientSites\aztectechnologies.net\paroissesaintremi.online\ClientApp\dist\main-server.js:1939:412)
        Current directory is: C:\ClientSites\aztectechnologies.net\paroissesaintremi.online

        at Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance.<InvokeExportAsync>d__7`1.MoveNext()
        --- End of stack trace from previous location where exception was thrown ---
        at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
        at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)

alexbenitez avatar Nov 05 '17 05:11 alexbenitez

yes,vs2017 Release run console error: "...Prerendering failed because of error: SyntaxError: Invalid regular expression: /^[_A-Za- ... ". Including error and part of the stack trace below:

but vs2017 debug run iisexpress OK; vs2017 Release run iisexpress error:

An error occurred while starting the application.

AggregateException: One or more errors occurred. (Cannot find module './wwwroot/dist/vendor-manifest.json' Error: Cannot find module './wwwroot/dist/vendor-manifest.json' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at module.exports (F:\test\aspnetcore-angular2-universal\webpack.config.js:51:27) at createWebpackDevServer (F:\test\aspnetcore-angular2-universal\node_modules\aspnet-webpack\WebpackDevMiddleware.js:194:31) at createWebpackDevServer (C:\Users\arlen\AppData\Local\Temp\bruj3kay.nrv:74:50) at C:\Users\arlen\AppData\Local\Temp\i4jdk5mx.zmu:114:19 at IncomingMessage. (C:\Users\arlen\AppData\Local\Temp\i4jdk5mx.zmu:133:38) at emitNone (events.js:86:13)) System.Threading.Tasks.Task.GetResultCore(bool waitCompletionNotification)

NodeInvocationException: Cannot find module './wwwroot/dist/vendor-manifest.json' Error: Cannot find module './wwwroot/dist/vendor-manifest.json' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at module.exports (F:\test\aspnetcore-angular2-universal\webpack.config.js:51:27) at createWebpackDevServer (F:\test\aspnetcore-angular2-universal\node_modules\aspnet-webpack\WebpackDevMiddleware.js:194:31) at createWebpackDevServer (C:\Users\arlen\AppData\Local\Temp\bruj3kay.nrv:74:50) at C:\Users\arlen\AppData\Local\Temp\i4jdk5mx.zmu:114:19 at IncomingMessage. (C:\Users\arlen\AppData\Local\Temp\i4jdk5mx.zmu:133:38) at emitNone (events.js:86:13) Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance+d__7.MoveNext()

AggregateException: One or more errors occurred. (Cannot find module './wwwroot/dist/vendor-manifest.json' Error: Cannot find module './wwwroot/dist/vendor-manifest.json' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at module.exports (F:\test\aspnetcore-angular2-universal\webpack.config.js:51:27) at createWebpackDevServer (F:\test\aspnetcore-angular2-universal\node_modules\aspnet-webpack\WebpackDevMiddleware.js:194:31) at createWebpackDevServer (C:\Users\arlen\AppData\Local\Temp\bruj3kay.nrv:74:50) at C:\Users\arlen\AppData\Local\Temp\i4jdk5mx.zmu:114:19 at IncomingMessage. (C:\Users\arlen\AppData\Local\Temp\i4jdk5mx.zmu:133:38) at emitNone (events.js:86:13)) System.Threading.Tasks.Task.GetResultCore(bool waitCompletionNotification) Microsoft.AspNetCore.Builder.WebpackDevMiddleware.UseWebpackDevMiddleware(IApplicationBuilder appBuilder, WebpackDevMiddlewareOptions options) AspCoreServer.Startup.Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, SpaDbContext context) in Startup.cs + app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() Microsoft.AspNetCore.Hosting.ConventionBasedStartup.Configure(IApplicationBuilder app) Microsoft.AspNetCore.ApplicationInsights.HostingStartup.ApplicationInsightsLoggerStartupFilter+<>c__DisplayClass0_1.b__0(IApplicationBuilder builder) Microsoft.ApplicationInsights.AspNetCore.ApplicationInsightsStartupFilter+<>c__DisplayClass0_0.b__0(IApplicationBuilder app) Microsoft.AspNetCore.Server.IISIntegration.IISSetupFilter+<>c__DisplayClass3_0.b__0(IApplicationBuilder app) Microsoft.AspNetCore.Hosting.Internal.AutoRequestServicesStartupFilter+<>c__DisplayClass0_0.b__0(IApplicationBuilder builder) Microsoft.AspNetCore.Hosting.Internal.WebHost.BuildApplication()

Show raw exception details NodeInvocationException: Cannot find module './wwwroot/dist/vendor-manifest.json' Error: Cannot find module './wwwroot/dist/vendor-manifest.json' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at module.exports (F:\test\aspnetcore-angular2-universal\webpack.config.js:51:27) at createWebpackDevServer (F:\test\aspnetcore-angular2-universal\node_modules\aspnet-webpack\WebpackDevMiddleware.js:194:31) at createWebpackDevServer (C:\Users\arlen\AppData\Local\Temp\bruj3kay.nrv:74:50) at C:\Users\arlen\AppData\Local\Temp\i4jdk5mx.zmu:114:19 at IncomingMessage. (C:\Users\arlen\AppData\Local\Temp\i4jdk5mx.zmu:133:38) at emitNone (events.js:86:13) Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance+d__7.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) System.Runtime.CompilerServices.TaskAwaiter.GetResult() Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance+d__13.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) System.Runtime.CompilerServices.TaskAwaiter.GetResult() Microsoft.AspNetCore.NodeServices.NodeServicesImpl+d__10.MoveNext() System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() Microsoft.AspNetCore.NodeServices.NodeServicesImpl+d__10.MoveNext()

Show raw exception details Microsoft.AspNetCore.NodeServices.HostingModels.NodeInvocationException: Cannot find module './wwwroot/dist/vendor-manifest.json' Error: Cannot find module './wwwroot/dist/vendor-manifest.json' at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at module.exports (F:\test\aspnetcore-angular2-universal\webpack.config.js:51:27) at createWebpackDevServer (F:\test\aspnetcore-angular2-universal\node_modules\aspnet-webpack\WebpackDevMiddleware.js:194:31) at createWebpackDevServer (C:\Users\arlen\AppData\Local\Temp\bruj3kay.nrv:74:50) at C:\Users\arlen\AppData\Local\Temp\i4jdk5mx.zmu:114:19 at IncomingMessage. (C:\Users\arlen\AppData\Local\Temp\i4jdk5mx.zmu:133:38) at emitNone (events.js:86:13) at Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance.d__71.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.d__131.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.TaskAwaiter1.GetResult() at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.d__101.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Microsoft.AspNetCore.NodeServices.NodeServicesImpl.<InvokeExportWithPossibleRetryAsync>d__101.MoveNext()

arlenniu avatar Nov 06 '17 13:11 arlenniu

I’ll take a look tomorrow! Must of forgotten to update something there for prod builds... if anyone finds out what it is, let us know!

MarkPieszak avatar Nov 06 '17 20:11 MarkPieszak

Thank you! I also found that the error: (Error: SyntaxError: Invalid regular expression: / ^), I use Chrome to refresh the page, the page is successful; But AggregateException: One or more errors occurred. (Can not find module './wwwroot/dist/vendor-manifest.json', I use Chrome to refresh the page, unsuccessfully. As a beginner, do not know the details of ng5.0universal change @nguniversal; @ angular / platform-server and so on. I compare GIT history, did not find package.json and webpack.config.vendor.js, the package conflict or missing something. Summary: debug mode successful, release mode unsuccessful. vs2017 posted to AZURE, debug and release, are http500;

arlenniu avatar Nov 08 '17 03:11 arlenniu

looks like I have related issue. On production build in chrome it throw this error: main-client.js:299 Uncaught SyntaxError: Invalid regular expression: /^[_A-Za-zÀ-ÖØ-öø-˿Ͱ-ͽͿ-῿‌-‍⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-��-󯰀-�:][-._A-Za-z0-9·À-ÖØ-öø-˿̀-ͽͿ-῿‌‍‿⁀⁰-↏Ⰰ-⿯、-퟿豈-﷏ﷰ-��-󯰀-�:]*$/: Range out of order in character class at new RegExp () at Object. (main-client.js:299) at t (main-client.js:1) at Object. (main-client.js:226) at t (main-client.js:1) at Object. (main-client.js:299) at t (main-client.js:1) at Object. (main-client.js:226) at t (main-client.js:1) at Object. (main-client.js:431)

consigliory avatar Nov 08 '17 11:11 consigliory

Same here, seems that some issues occurred during minification, Commenting out of UglifyJS plugin fixing this.

etatuev avatar Nov 08 '17 12:11 etatuev

Hi statuev,

I think that I tried the same but likely I deployed the wrong package (I got the same error). I tried many ad-hoc things. Do you mind copy and pasting the lines that you commented out so I can give it a try? Is this in the webpack configuration?

alexbenitez avatar Nov 08 '17 13:11 alexbenitez

Same issue on build:prod, i've tried to comment uglyfy without any result.

JulienBroutier avatar Nov 08 '17 14:11 JulienBroutier

@alexbenitez

Basically, it will be any UglifyJS plugin entry in webpack configuration. I'm using slightly modified version of this package for my own project, so maybe there was something more. I'll try to repeat steps for exactly this package. However, after resolving I've got new strange issue (only for server-side render) - ENONENT 'project_root_folder/my-component.view.html'

etatuev avatar Nov 08 '17 15:11 etatuev

This is exactly what i have when i comment uglyfy. Server side can't find a component.

JulienBroutier avatar Nov 08 '17 15:11 JulienBroutier

Yep... that's what I got without uglyfy. The Starter as is does not work in Prod mode.

alexbenitez avatar Nov 08 '17 15:11 alexbenitez

Hi,

yea. there is uglyfy

UglifyJS unescapes \u0000 and other unicode char code strings and converts them . this results in some libraries (eg,js-base64,firebase) getting screwed up, and Chrome refusing to load the extension b/c theinjectionisn'tutf-8`.

I had a similar problem and it happened because I'm using WebPack's uglify which does the compression of unicode characters to UTF-8 and the server wasn't specifying UTF-8 as the charset causing the browser to fail to properly parse it. (https://github.com/lodash/lodash/issues/2625)

need to set output: { ascii_only: true, beautify: false, }(https://github.com/zalmoxisus/crossbuilder/commit/6c70ff4650efd346211c221d97390a143cf5ef8e)

also I noticed we use 0.4.6, and 1.0.0 version

Eugene

bigWebApps avatar Nov 10 '17 09:11 bigWebApps

I tried replacing Uglify with the following (as per https://github.com/lodash/lodash/issues/2625) but unfortunately I get the error below:

         ... app.component.html' . Error: ENOENT: no such file or directory, open             

           // uglify setting
            new webpack.optimize.UglifyJsPlugin({
            comments: false,
            compress: {
              warnings: false
            },
             output: {
                        ascii_only: true,
                        beautify: false,
                }
          })

Hopefully someone finds and a solution. The starter is not very useful if it can't be deployed...

alexbenitez avatar Nov 11 '17 18:11 alexbenitez

We also have the same problem. When comment this code it is working in IIS Express/RELEASE mode but it's not solution. If publish - retrieving '

... app.component.html' . Error: ENOENT: no such file or directory, open

' Is it the problem in this plugin or something else?:

//new webpack.optimize.UglifyJsPlugin({
//             compress: false,
//             mangle: false
//            }),

GetTaxSolutions avatar Nov 12 '17 16:11 GetTaxSolutions

Seems like uglify is giving us problems, this is real strange... I’ll post back here when I know more!

Apologies everyone 😔

MarkPieszak avatar Nov 12 '17 16:11 MarkPieszak

Any workaround for this? commenting out UglifyJsPlugin just left me with another error

LiverpoolOwen avatar Nov 14 '17 13:11 LiverpoolOwen

Any workaround @MarkPieszak ?

husseinjahan avatar Nov 15 '17 11:11 husseinjahan

So a few updates, I'm still looking into it, and there seems to be an issue with Uglify, but actually you can remove that (realistically) from the server build, as it doesn't get "loaded" (since it is used outside of the browser), so minifying it, doesn't benefit in any way.

So the other problem ENOENT: no such file or directory, open 'app.component.html' seems to be coming from angular2-template-loader not doing its thing. Since it should be inlining the template, since we're not trying to load it here.

I'll keep looking, just wanted to give an update!

MarkPieszak avatar Nov 16 '17 03:11 MarkPieszak

problem with line 259 in main-server.js a="_A-Za-z\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0370-\u037d\u037f-\u1fff\u200c-\u200d\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd",u="-._A-Za-z0-9\xb7\xc0-\xd6\xd8-\xf6\xf8-\u02ff\u0300-\u037d\u037f-\u1fff\u200c\u200d\u203f\u2040\u2070-\u218f\u2c00-\u2fef\u3001-\ud7ff\uf900-\ufdcf\ufdf0-\ufffd"

I updated "webpack": "^3.8.1", "file-loader": "^1.1.5", "extract-text-webpack-plugin": "^3.0.2",

now uglify recognize ascii_only

so I can do

new webpack.optimize.UglifyJsPlugin({ output: { ascii_only: true, beautify: false, } }),

js files now CORRECT, no unicode strings

BUT error ENOENT: no such file or directory, open 'app.component.html' still exists

bigWebApps avatar Nov 16 '17 14:11 bigWebApps

also on production we use

@ngtools/webpack - NOT angular2-template-loader

line 34 in webpack.config.js use: isDevBuild ? ['awesome-typescript-loader?silent=true', 'angular2-template-loader', 'angular2-router-loader'] : '@ngtools/webpack'

bigWebApps avatar Nov 16 '17 14:11 bigWebApps