Impossible to start SSR : A server error occured
See original GitHub issue🐞 Bug report
What modules are related to this issue?
One of the two following ones, not sure…
- aspnetcore-engine
- builders
- common
- express-engine
- hapi-engine
Description
I am trying to move my application to Angular Universal. After running npm install -g @angular/cli
and updating a few configs (tsconfig.server.json, angular.json and app.module.ts) to fix first issues, I am seeing an error when running npm run dev:ssr
.
🔬 Minimal Reproduction
The few changes I did to fix first issues when trying to start the app were :
- adding
BrowserModule
to app.module.ts - updating the environments in angular.json so the names match the ones defined in our project
- adding
hammerjs
to the types list in tsconfig.server.json
🔥 Exception or Error
***/dist/***/server/main.js:1
var __defProp=Object.defineProperty,__name=(target,value)=>__defProp(target,"name",{value,configurable:!0});(()=>{var __webpack_modules__={42121:(module2,__unused_webpack_exports2,__webpack_require__2)=>{"use strict";var Negotiator=__webpack_require__2(14720),mime=__webpack_require__2(70394);function Accepts(req){if(!(this instanceof Accepts))return new Accepts(req);this.headers=req.headers,this.negotiator=new Negotiator(req)}function extToMime(type){return-1===type.indexOf("/")?mime.lookup(type):type}function validMime(type){return"string"==typeof type}module2.exports=Accepts,__name(Accepts,"Accepts"),Accepts.prototype.type=Accepts.prototype.types=function(types_){var types=types_;if(types&&!Array.isArray(types)){types=new Array(arguments.length);for(var i2=0;i2<types.length;i2++)types[i2]=arguments[i2]}if(!types||0===types.length)return this.negotiator.mediaTypes();if(!this.headers.accept)return types[0];var mimes=types.map(extToMime),accepts=this.negotiator.mediaTypes(mimes.filter(validMime)),first=accepts[0];return!!first&&types[mimes.indexOf(first)]},Accepts.prototype.encoding=Accepts.prototype.encodings=function(encodings_){var encodings=encodings_;if(encodings&&!Array.isArray(encodings)){encodings=new Array(arguments.length);for(var i2=0;i2<encodings.length;i2++)encodings[i2]=arguments[i2]}return encodings&&0!==encodings.length?this.negotiator.encodings(encodings)[0]||!1:this.negotiator.encodings()},Accepts.prototype.charset=Accepts.prototype.charsets=function(charsets_){var charsets=charsets_;if(charsets&&!Array.isArray(charsets)){charsets=new Array(arguments.length);for(var i2=0;i2<charsets.length;i2++)charsets[i2]=arguments[i2]}return charsets&&0!==charsets.length?this.negotiator.charsets(charsets)[0]||!1:this.negotiator.charsets()},Accepts.prototype.lang=Accepts.prototype.langs=Accepts.prototype.language=Accepts.prototype.languages=function(languages_){var languages=languages_;if(languages&&!Array.isArray(languages)){languages=new Array(arguments.length);for(var i2=0;i2<languages.length;i2++)languages[i2]=arguments[i2]}return languages&&0!==languages.length?this.negotiator.languages(languages)[0]||!1:this.negotiator.languages()},__name(extToMime,"extToMime"),__name(validMime,"validMime")},6645:(module2,exports2,__webpack_require__2)=>{"use strict";var deprecate2=__webpack_require__2(73546)("body-parser"),parsers=Object.create(null);function bodyParser(options){var opts={};if(options)for(var prop in options)"type"!==prop&&(opts[prop]=options[prop]);var _urlencoded=exports2.urlencoded(opts),_json=exports2.json(opts);return __name(function(req,res,next){_json(req,res,function(err2){if(err2)return next(err2);_urlencoded(req,res,next)})},"bodyParser")}function createParserGetter(name){return __name(function(){return loadParser(name)},"get")}function loadParser(parserName){var parser=parsers[parserName];if(void 0!==parser)return parser;switch(parserName){case"json":parser=__webpack_require__2(8714);break;case"raw":parser=__webpack_require__2(95108);break;case"text":parser=__webpack_require__2(8824);break;case"urlencoded":parser=__webpack_require__2(90570)}return parsers[parserName]=parser}exports2=module2.exports=deprecate2.function(bodyParser,"bodyParser: use individual json/urlencoded middlewares"),Object.defineProperty(exports2,"json",{configurable:!0,enumerable:!0,get:createParserGetter("json")}),Object.defineProperty(exports2,"raw",{configurable:!0,enumerable:!0,get:createParserGetter("raw")}),Object.defineProperty(exports2,"text",{configurable:!0,enumerable:!0,get:createParserGetter("text")}),Object.defineProperty(exports2,"urlencoded",{configurable:!0,enumerable:!0,get:createParserGetter("urlencoded")}),__name(bodyParser,"bodyParser"),__name(createParserGetter,"createParserGetter"),__name(loadParser,"loadParser")},76421:(module2,__unused_webpack_exports2,__webpack_require__2)=>{"use strict";var createError=__webpack_require__2(41347),getBody=__webpack_require__2(67386),iconv=__webpack_require__2(41614),onFinished=__webpack_require__2(99669),zlib=__webpack_require__2(59796);function read(req,res,next,parse,debug,options){var length,stream,opts=options;req._body=!0;var encoding=null!==opts.encoding?opts.encoding:null,verify=opts.verify;try{length=(stream=contentstream(req,debug,opts.inflate)).length,stream.length=void 0}catch(err2){return next(err2)}if(opts.length=length,opts.encoding=verify?null:encoding,null===opts.encoding&&null!==encoding&&!iconv.encodingExists(encoding))return next(createError(415,'unsupported charset "'+encoding.toUpperCase()+'"',{charset:encoding.toLowerCase(),type:"charset.unsupported"}));debug("read body"),getBody(stream,opts,function(error,body){var _error;if(error)return _error="encoding.unsupported"===error.type?createError(415,'unsupported charset "'+encoding.toUpperCase()+'"',{charset:encoding.toLowerCase(),type:"charset.unsupported"}):createError(400,error),stream.resume(),void onFinished(req,__name(function(){next(createError(400,_error))},"onfinished"));if(verify)try{debug("verify body"),verify(req,res,body,encoding)}catch(err2){return void next(createError(403,err2,{body,type:err2.type||"entity.verify.failed"}))}var str=body;try{debug("parse body"),str="string"!=typeof body&&null!==encoding?iconv.decode(body,encoding):body,req.body=parse(str)}catch(err2){return void next(createError(400,err2,{body:str,type:err2.type||"entity.parse.failed"}))}next()})}function contentstream(req,debug,inflate){var stream,encoding=(req.headers["content-encoding"]||"identity").toLowerCase(),length=req.headers["content-length"];if(debug('content-encoding "%s"',encoding),!1===inflate&&"identity"!==encoding)throw createError(415,"content encoding unsupported",{encoding,type:"encoding.unsupported"});switch(encoding){case"deflate":stream=zlib.createInflate(),debug("inflate body"),req.pipe(stream);break;case"gzip":stream=zlib.createGunzip(),debug("gunzip body"),req.pipe(stream);break;case"identity":(stream=req).length=length;break;default:throw createError(415,'unsupported content encoding "'+encoding+'"',{encoding,type:"encoding.unsupported"})}return stream}module2.exports=read,__name(read,"read"),__name(contentstream,"contentstream")},8714:(module2,__unused_webpack_exports2,__webpack_require__2)=>{"use strict";var bytes=__webpack_require__2(49974),contentType=__webpack_require__2(69065),createError=__webpack_require__2(41347),debug=__webpack_require__2(44041)("body-parser:json"),read=__webpack_require__2(76421),typeis=__webpack_require__2(69820);module2.exports=json;var FIRST_CHAR_REGEXP=/^[\x20\x09\x0a\x0d]*(.)/;function json(options){var opts=options||{},limit="number"!=typeof opts.limit?bytes.parse(opts.limit||"100kb"):opts.limit,inflate=!1!==opts.inflate,reviver=opts.reviver,strict=!1!==opts.strict,type=opts.type||"application/json",verify=opts.verify||!1;if(!1!==verify&&"function"!=typeof verify)throw new TypeError("option verify must be function");var shouldParse="function"!=typeof type?typeChecker(type):type;function parse(body){if(0===body.length)return{};if(strict){var first=firstchar(body);if("{"!==first&&"["!==first)throw debug("strict violation"),createStrictSyntaxError(body,first)}try{return debug("parse json"),JSON.parse(body,reviver)}catch(e){throw normalizeJsonSyntaxError(e,{message:e.message,stack:e.stack})}}return __name(parse,"parse"),__name(function(req,res,next){if(req._body)return debug("body already parsed"),void next();if(req.body=req.body||{},!typeis.hasBody(req))return debug("skip empty body"),void next();if(debug("content-type %j",req.headers["content-type"]),!shouldParse(req))return debug("skip parsing"),void next();var charset=getCharset(req)||"utf-8";if("utf-"!==charset.substr(0,4))return debug("invalid charset"),void next(createError(415,'unsupported charset "'+charset.toUpperCase()+'"',{charset,type:"charset.unsupported"}));read(req,res,next,parse,debug,{encoding:charset,inflate,limit,verify})},"jsonParser")}function createStrictSyntaxError(str,char){var index=str.indexOf(char),partial=str.substring(0,index)+"#";try{throw JSON.parse(partial),new SyntaxError("strict violation")}catch(e){return normalizeJsonS
A server error has occurred.
node exited with 1 code.
connect ECONNREFUSED 127.0.0.1:56683
🌍 Your Environment
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 13.0.3
Node: 16.13.0
Package Manager: npm 8.1.0
OS: darwin x64
Angular CLI: 13.1.2
Node: 16.13.1
Package Manager: npm 8.1.2
OS: darwin x64
Angular: 13.1.1
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, material, platform-browser
... platform-browser-dynamic, router, youtube-player
Package Version
---------------------------------------------------------
@angular-devkit/architect 0.1301.2
@angular-devkit/build-angular 13.1.2
@angular-devkit/core 13.1.2
@angular-devkit/schematics 13.1.2
@angular/cli 13.1.2
@nguniversal/builders 13.0.1
@nguniversal/express-engine 13.0.1
@schematics/angular 13.1.2
rxjs 7.5.2
typescript 4.4.4
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:6
Top Results From Across the Web
Angular Universal dev:ssr works fine but serve:ssr shows .js
When I use the Angular Universal dev:ssr script to test the performance, ... if any error occur during server start up it broken...
Read more >Logging and error management best practices in SSR apps
Handle errors and log them gracefully in your next web app with these best practice guidelines with examples using Next.js and Nuxt.js.
Read more >Angular Universal: real app problems - InDepth.Dev
SSR issues in Angular · 1. Infinite page loading · 2. Lack of cache out of the box · 3. Server errors of...
Read more >Troubleshoot a Reporting Services installation - SQL Server ...
You see an error message indicating the URL is not configured · A report server URL is not configured. Use the SSRS Integration...
Read more >Best Practices for 5xx HTTP Response Codes - AT&T Developer
This error occurs when the server is unable to handle requests due to a temporary overload or due to the server being temporarily...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here is the whole output when I run
npm run dev:ssr
:I have also updated the Angular version in my initial post
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.