Angular-cli: ng serve: Cannot read property 'text' of undefined

Created on 17 Jan 2017  路  35Comments  路  Source: angular/angular-cli

OS?

Mac OS X El Capitan

Versions.

angular-cli: 1.0.0-beta.25.5, beta.24, beta.22-1
node: 7.3.0 or 6.9.2
os: darwin x64
@angular/common: 2.3.1
@angular/compiler: 2.3.1
@angular/core: 2.3.1
@angular/flex-layout: 2.0.0-beta.1
@angular/forms: 2.3.1
@angular/http: 2.3.1
@angular/material: 2.0.0-beta.1
@angular/platform-browser: 2.3.1
@angular/platform-browser-dynamic: 2.3.1
@angular/platform-server: 2.3.1
@angular/router: 3.3.1
@angular/compiler-cli: 2.3.1

Repro steps.

Upgrading from beta.19-3 to beta.25.5.

Run upgrade guide including merging in of ng init output.

The log given by the failure.

ERROR in ./src/environments/environment.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
    at IdentifierObject.TokenOrIdentifierObject.getText (/Users/splaktar/Git/tf/webapp/node_modules/typescript/lib/typescript.js:53369:56)
    at /Users/splaktar/Git/tf/webapp/node_modules/@ngtools/webpack/src/loader.js:83:72
    at Array.some (native)
    at /Users/splaktar/Git/tf/webapp/node_modules/@ngtools/webpack/src/loader.js:83:32
    at Array.filter (native)
    at _removeModuleId (/Users/splaktar/Git/tf/webapp/node_modules/@ngtools/webpack/src/loader.js:82:10)
    at /Users/splaktar/Git/tf/webapp/node_modules/@ngtools/webpack/src/loader.js:167:48
 @ ./src/main.ts 4:0-57
 @ multi main

ERROR in ./src/app/app.module.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
    at IdentifierObject.TokenOrIdentifierObject.getText (/Users/splaktar/Git/tf/webapp/node_modules/typescript/lib/typescript.js:53369:56)
    at /Users/splaktar/Git/tf/webapp/node_modules/@ngtools/webpack/src/loader.js:83:72
    at Array.some (native)
    at /Users/splaktar/Git/tf/webapp/node_modules/@ngtools/webpack/src/loader.js:83:32
    at Array.filter (native)
    at _removeModuleId (/Users/splaktar/Git/tf/webapp/node_modules/@ngtools/webpack/src/loader.js:82:10)
    at /Users/splaktar/Git/tf/webapp/node_modules/@ngtools/webpack/src/loader.js:167:48
 @ ./src/main.ts 5:0-45
 @ multi main

Mention any other details that might be useful.

This seems to be related to https://github.com/angular/angular-cli/blob/master/packages/%40ngtools/webpack/src/loader.ts#L94 which has two calls to .getText() which seems to assume that all properties have a name field and doesn't check to verify that name is defined.

refactor.findAstNodes(sourceFile, ts.SyntaxKind.ObjectLiteralExpression, true)
    // Get all their property assignments.
    .filter((node: ts.ObjectLiteralExpression) =>
      node.properties.some(prop => prop.name.getText() == 'moduleId'))
    .forEach((node: ts.ObjectLiteralExpression) => {
      const moduleIdProp = node.properties.filter((prop: ts.ObjectLiteralElement, idx: number) => {
        return prop.name.getText() == 'moduleId';
      })[0];
      // get the trailing comma
      const moduleIdCommaProp = moduleIdProp.parent.getChildAt(1).getChildren()[1];
      refactor.removeNodes(moduleIdProp, moduleIdCommaProp);
    });

My ./src/environments/environment.ts

export const environment = {
  production: false
};

My ./src/app/app.module.ts

import {BrowserModule} from '@angular/platform-browser';
import {NgModule} from '@angular/core';
import {HttpModule, JsonpModule} from '@angular/http';
import {NgbModule} from '@ng-bootstrap/ng-bootstrap';

import {FlexLayoutModule} from '@angular/flex-layout';
import {MaterialModule} from '@angular/material';
import 'hammerjs';

import {AppRoutingModule} from './app-routing.module';
import {SharedModule} from './shared';
import {NavService} from './nav.service';
import {UsersService} from './users.service';
import {ListingsService} from './listings.service';
import {ListhubMetricsService} from './listhub-metrics.service';
import {GoogleAnalyticsService} from './google-analytics.service';

import {AppComponent} from './app.component';
import {GlobalStylesComponent} from './shared/global-styles';
import {TopNavComponent} from './top-nav';

import {LandingComponent} from './+landing';
import {ListingsComponent} from './+listings';
import {ListingComponent} from './+listing';
import {ProfileComponent} from './+profile';
import {RegisterComponent} from './+register';

import {PropertyCardComponent} from './property-card';
import {PropertyInfoComponent} from './property-info';
import {PropertyGalleryComponent} from './property-gallery';
import {PropertyAppraiserInfoComponent} from './property-appraiser-info';
import {PropertyMapComponent} from './property-map';
import {PropertyDisclaimerComponent} from './property-disclaimer';
import {FeaturedListingsComponent} from './featured-listings';
import {BrokerInfoComponent} from './broker-info/broker-info.component';

import {BathsFilterComponent} from './property-filters/baths-filter/baths-filter.component';
import {BedsFilterComponent} from './property-filters/beds-filter/beds-filter.component';
import {PriceFilterComponent} from './property-filters/price-filter/price-filter.component';
import {SqftFilterComponent} from './property-filters/sqft-filter/sqft-filter.component';
import {TypeFilterComponent} from './property-filters/type-filter/type-filter.component';
import {ZipFilterComponent} from './property-filters/zip-filter/zip-filter.component';
import {PropertyFiltersComponent} from './property-filters/property-filters.component';
import {PropertyFiltersService} from './property-filters/property-filters.service';
import {NewsletterSubscribeComponent} from './newsletter-subscribe/newsletter-subscribe.component';

@NgModule({
  declarations: [
    AppComponent,
    GlobalStylesComponent,
    TopNavComponent,
    LandingComponent,
    ListingsComponent,
    ListingComponent,
    ProfileComponent,
    RegisterComponent,
    PropertyCardComponent,
    PropertyInfoComponent,
    PropertyGalleryComponent,
    PropertyAppraiserInfoComponent,
    PropertyMapComponent,
    PropertyDisclaimerComponent,
    FeaturedListingsComponent,
    BathsFilterComponent,
    BedsFilterComponent,
    PriceFilterComponent,
    SqftFilterComponent,
    TypeFilterComponent,
    ZipFilterComponent,
    PropertyFiltersComponent,
    FeaturedListingsComponent,
    BrokerInfoComponent,
    NewsletterSubscribeComponent
  ],
  imports: [
    BrowserModule,
    HttpModule,
    JsonpModule,
    AppRoutingModule,
    MaterialModule.forRoot(),
    FlexLayoutModule.forRoot(),
    NgbModule.forRoot(),
    SharedModule
  ],
  providers: [
    ListingsService,
    NavService,
    UsersService,
    ListhubMetricsService,
    GoogleAnalyticsService,
    PropertyFiltersService
  ],
  bootstrap: [AppComponent]
})
export class AppModule {}

It would be nice if this error message was more user friendly and gave the user some idea of what property was not properly defined or what part of the code/what module was being processed.

1 (urgent) bufix

Most helpful comment

@metavurt Thank you very much for your answer.
I've tried npm cache clear and installing everything from scratch already, but always copied my files in there.

After your answer I decided to try to add the main parts of the application slowly and one by one and found the mistake.
It was indeed in my own code, but I the debugging message didn't make sense anyway.

For future reference:
My mistake was the wrong use of "export default".

I used to export an object like this:

export default {
   ...
};

This used to work with the older version of typescript and angular-cli.
I've changed the file to:

export const config = {
   ...
};

and now everything works.
I hope it helps someone.

Thank you for help @metavurt though

All 35 comments

I was able to get ng serve and ng build to work with beta.21.

But I can't do ng build -aot

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/splaktar/Git/tf/webapp/src'
 @ ./src/main.ts 4:0-74
 @ multi main

ERROR in ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js
Module not found: Error: Can't resolve '/Users/splaktar/Git/tf/webapp/src/$$_gendir' in '/Users/splaktar/Git/tf/webapp/node_modules/@angular/core/src/linker'
 @ ./~/@angular/core/src/linker/system_js_ng_module_factory_loader.js 69:15-36 85:15-102
 @ ./~/@angular/core/src/linker.js
 @ ./~/@angular/core/src/core.js
 @ ./~/@angular/core/index.js
 @ ./src/main.ts
 @ multi main

Dealing with a similar issue on angular-cli: 1.0.0-beta.25.5 (was also present in angular-cli: 1.0.0-beta.24) whenever I try to run ng build with the --env switch. The build works just fine whenever I exclude --env; however, as soon as I add something like --env=prod (corresponding to my environment.prod.ts file) I get the same error:

ERROR in ./config/environment.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
...

Interestingly, the build succeeds with --env if I modify the environment import from my ./src/main.ts file:

import './polyfills.ts';

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
import { environment } from '../config/environment';
import { AppModule } from "./app/app.module";

if (environment.production) {
  enableProdMode();
}

platformBrowserDynamic().bootstrapModule(AppModule);

To point directly to the environment file I'm trying to use (e.g., environment.prod.ts):

...
import { environment } from '../config/environment.prod';
...

Obviously this doesn't solve anything since it breaks the whole point of the --env switch, but hopefully this information will help lead to a solution.

@Splaktar - My issue was also resolved by moving back to angular-cli: 1.0.0-beta.21. Thanks for the suggestion. Hopefully this gets fixed in the coming versions.

I get the same error in beta.25.5 (was working fine in beta.24):

ERROR in ./src/environments/environment.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
    at IdentifierObject.TokenOrIdentifierObject.getText (c:\???\???\node_modules\typescript\lib\typescript.js:53644:56)
    at c:\???\???\node_modules\@ngtools\webpack\src\loader.js:83:72
    at Array.some (native)
    at c:\???\???\node_modules\@ngtools\webpack\src\loader.js:83:32
    at Array.filter (native)
    at _removeModuleId (c:\???\???\node_modules\@ngtools\webpack\src\loader.js:82:10)
    at c:\???\???\node_modules\@ngtools\webpack\src\loader.js:167:48
 @ ./src/main.ts 5:20-57
 @ multi main

Note: the paths in the error have been redacted.
The same error also shows for ./src/app/app.module.ts as well as all 5 of my modules

@Splaktar - adding the following property to my ./src/tsconfig.json file fixed the --aot error in beta.21:

"exclude": [ "test.ts" ]

@saverett I also needed to do the following in my tsconfig.json:

  "files": [
    "typings.d.ts",
    "main"
  ]

After that I was able to get -aot working, even in beta.25.5!

In addition, I updated a lot of dependencies beyond what is the default in angular-cli:

dependencies": {
    "@angular/common": "2.4.3",
    "@angular/compiler": "2.4.3",
    "@angular/core": "2.4.3",
    "@angular/flex-layout": "2.0.0-beta.3",
    "@angular/forms": "2.4.3",
    "@angular/http": "2.4.3",
    "@angular/material": "2.0.0-beta.1",
    "@angular/platform-browser": "2.4.3",
    "@angular/platform-browser-dynamic": "2.4.3",
    "@angular/platform-server": "2.4.3",
    "@angular/router": "3.4.3",
    "@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.18",
    "angular2-google-maps": "0.17.0",
    "angularfire2": "2.0.0-beta.7",
    "bootstrap": "4.0.0-alpha.6",
    "core-js": "2.4.1",
    "firebase": "3.6.6",
    "hammerjs": "2.0.8",
    "rxjs": "5.0.3",
    "ts-helpers": "1.1.2",
    "zone.js": "0.7.5"
  },
  "devDependencies": {
    "@angular/compiler-cli": "2.4.3",
    "@types/express": "4.0.34",
    "@types/glob": "5.0.30",
    "@types/google-maps": "3.2.0",
    "@types/googlemaps": "3.26.0",
    "@types/gulp": "3.8.32",
    "@types/jasmine": "2.5.40",
    "@types/node": "7.0.0",
    "@types/request": "0.0.39",
    "@types/zone.js": "0.0.27",
    "angular-cli": "1.0.0-beta.25.5",
    "codelyzer": "2.0.0-beta.4",
    "gulp": "3.9.1",
    "gulp-rename": "1.2.2",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "3.1.0",
    "karma": "1.3.0",
    "karma-chrome-launcher": "2.0.0",
    "karma-cli": "1.0.1",
    "karma-jasmine": "1.1.0",
    "karma-remap-istanbul": "0.4.0",
    "protractor": "5.0.0",
    "stylelint": "7.7.1",
    "ts-node": "2.0.0",
    "tslint": "4.3.1",
    "typescript": "2.0.10",
    "yargs": "6.6.0"
  }

This is still a think for me, even in beta 26, when using "ng serve --prod" but it works fine if you do "ng serve --prod --aot"

Was this supposed to be fixed? I never had this issue until today..

Actually, nvm.. mine is the same error from a diff location :

Module build failed: TypeError: Cannot read property 'text' of undefined
    at Object.getTokenPosOfNode (/Users/em255017/GitHub/covalent-quickstart/node_modules/typescript/lib/typescript.js:6635:71)
    at IdentifierObject.TokenOrIdentifierObject.getStart (/Users/em255017/GitHub/covalent-quickstart/node_modules/typescript/lib/typescript.js:78683:23)
    at IdentifierObject.TokenOrIdentifierObject.getText (/Users/em255017/GitHub/covalent-quickstart/node_modules/typescript/lib/typescript.js:78704:77)
    at /Users/em255017/GitHub/covalent-quickstart/node_modules/@ngtools/webpack/src/loader.js:119:42
    at Array.filter (native)
    at /Users/em255017/GitHub/covalent-quickstart/node_modules/@ngtools/webpack/src/loader.js:118:14
    at Array.forEach (native)
    at _removeDecorators (/Users/em255017/GitHub/covalent-quickstart/node_modules/@ngtools/webpack/src/loader.js:109:10)
    at /Users/em255017/GitHub/covalent-quickstart/node_modules/@ngtools/webpack/src/loader.js:280:48
 @ ./src/$$_gendir/app/app.module.ngfactory.ts 68:0-49
 @ ./src/main.ts
 @ multi webpack-dev-server/client?http://localhost:4200/ ./src/main.ts

@emoralesb05, have you found a solution for this? I have the same issue after upgrading to covalent 1.0.0-beta.1 l. I on @angular/cli-beta.31.

Likewise getting this error on @angular/cli-beta.31, and have no clue how to go about fixing it.

@jimdubbs, are you also using covalent?
For me using covalent-nightly fixed the issue. I do actually know what had caused it.

@istvanszoboszlai no im not using covalent. I get the below error on each of my 5 angular services wen trying to build with the --prod flag. No idea how to solve.

ERROR in ../x-shared/services/user.service.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
    at Object.getTokenPosOfNode (/Users/jimmywestcott/Documents/github/QMonitor/web/node_modules/typescript/lib/typescript.js:5692:71)
    at IdentifierObject.TokenOrIdentifierObject.getStart (/Users/jimmywestcott/Documents/github/QMonitor/web/node_modules/typescript/lib/typescript.js:53623:23)
    at IdentifierObject.TokenOrIdentifierObject.getText (/Users/jimmywestcott/Documents/github/QMonitor/web/node_modules/typescript/lib/typescript.js:53644:77)
    at refactor.findAstNodes.filter (/Users/jimmywestcott/Documents/github/QMonitor/web/node_modules/@ngtools/webpack/src/loader.js:138:44)
    at Array.filter (native)
    at refactor.findAstNodes.forEach.node (/Users/jimmywestcott/Documents/github/QMonitor/web/node_modules/@ngtools/webpack/src/loader.js:137:14)
    at Array.forEach (native)
    at _removeDecorators (/Users/jimmywestcott/Documents/github/QMonitor/web/node_modules/@ngtools/webpack/src/loader.js:128:10)
    at Promise.resolve.then (/Users/jimmywestcott/Documents/github/QMonitor/web/node_modules/@ngtools/webpack/src/loader.js:304:33)
 @ ./src/$$_gendir/app/app.module.ngfactory.ts 99:0-65
 @ ./src/main.ts
 @ multi ./src/main.ts

I have the same problem. Output of my ng version:

@angular/cli: 1.0.0-beta.32.3
node: 7.5.0
os: darwin x64
@angular/common: 2.4.8
@angular/compiler: 2.4.8
@angular/core: 2.4.8
@angular/forms: 2.4.8
@angular/http: 2.4.8
@angular/platform-browser: 2.4.8
@angular/platform-browser-dynamic: 2.4.8
@angular/router: 3.4.8
@angular/cli: 1.0.0-beta.32.3
@angular/compiler-cli: 2.4.8
@ngtools/webpack: 1.2.10

@emoralesb05 somehow solved it in Covalent. Maybe he knows what the root of the issue was

In our case (covalent), it was because the CLI was picking the ts files instead of the js files. (since we were publishing the ts files to npm too).

Removing the source files from the publishing process fixed it for us.

@emoralesb05, can you expound on:

Removing the source files from the publishing process fixed it for us.

I've literally added one 3rd party component for a ui item, and cannot build prod. No fun.

So, check if the 3rd party component has ts source files published in the module (excluding the d.ts files since those are needed).

The CLI errored out in our case if they are there.

e.g.

/node_modules/@covalent/core/index.ts was the guilty file, so we had to remove the source typescript files from the publishing process (which was our fault to begin with since they shouldnt be published, only the js files should be published)

Good grief. That did it. @emoralesb05 THANK YOU.

Ouch, I've just been bitten by this in an all-typescript monorepo. We really want to get rid of the extra compilation step and working with JS, just have ts in node_modules.

@konrad-garus - as per @emoralesb05, it is just getting rid of source ts file of the 3rd party files that you are using, except for, of course, the ...d.ts file. Removing the one source file literally cleared up all issues for me and I have been moving forward with no issues. And it is not all ts; the js files are fine. It seems to be an issue with how some packages are being deployed.

@metavurt This is exactly my point. I do want TS files in there. I have a monorepo with a bunch of TS packages managed by Lerna, which basically copies (or symlinks) the packages into node_modules. I want them to just build correctly with plain TS depedencies, so that I don't have to compile each of them to ES.

@metavurt but what if I prefer to have 3rd-party libraries in TS instead of JS? It's really convenient.
I understand that removing TS files from the library is just a workaround.

@hansl, I've just installed version 1.0.0-rc.1 and created a test project wtih ng new trese-sitemobile. Didn't change anything in the project.

ng build works fine.
ng serve works fine.
ng build --prod fails.
ng serve --prod fails.

Here's the output for ng version in the project folder:

@angular/cli: 1.0.0-rc.1
node: 6.10.0
os: win32 x64
@angular/common: 2.4.9
@angular/compiler: 2.4.9
@angular/core: 2.4.9
@angular/forms: 2.4.9
@angular/http: 2.4.9
@angular/platform-browser: 2.4.9
@angular/platform-browser-dynamic: 2.4.9
@angular/router: 3.4.9
@angular/cli: 1.0.0-rc.1
@angular/compiler-cli: 2.4.9

And here's the output for ng build --prod:

D:\dev\SiteMobile\trese-sitemobile>ng build --prod
Hash: 2bbdb9e96c288ee40e43
Time: 9287ms
chunk    {0} polyfills.28a09e20f5736e6a970b.bundle.js (polyfills) 153 kB {3} [initial] [rendered]
chunk    {1}  (styles) 1.72 kB {3} [initial] [rendered]
chunk    {2} main.69441850b2d22bca2f39.bundle.js (main) 1.18 MB [initial] [rendered]
chunk    {3} inline.dcc04371985807de2ad8.bundle.js (inline) 0 bytes [entry] [rendered]

ERROR in D:/dev/Projects/SiteMobile/trese-sitemobile/src/app/app.module.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
    at Object.getTokenPosOfNode (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\typescript\lib\typescript.js:5692:71)
    at IdentifierObject.TokenOrIdentifierObject.getStart (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\typescript\lib\typescript.js:53623:23)
    at IdentifierObject.TokenOrIdentifierObject.getText (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\typescript\lib\typescript.js:53644:77)
    at refactor.findAstNodes.filter (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\@ngtools\webpack\src\loader.js:139:44)
    at Array.filter (native)
    at refactor.findAstNodes.forEach.node (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\@ngtools\webpack\src\loader.js:138:14)
    at Array.forEach (native)
    at _removeDecorators (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\@ngtools\webpack\src\loader.js:129:10)
    at Promise.resolve.then (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\@ngtools\webpack\src\loader.js:292:33)
 @ ./src/$$_gendir/app/app.module.ngfactory.ts 13:0-48
 @ D:/dev/Projects/SiteMobile/trese-sitemobile/src/main.ts
 @ multi ./src/main.ts

ERROR in D:/dev/Projects/SiteMobile/trese-sitemobile/src/app/app.component.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
    at Object.getTokenPosOfNode (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\typescript\lib\typescript.js:5692:71)
    at IdentifierObject.TokenOrIdentifierObject.getStart (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\typescript\lib\typescript.js:53623:23)
    at IdentifierObject.TokenOrIdentifierObject.getText (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\typescript\lib\typescript.js:53644:77)
    at refactor.findAstNodes.filter (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\@ngtools\webpack\src\loader.js:139:44)
    at Array.filter (native)
    at refactor.findAstNodes.forEach.node (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\@ngtools\webpack\src\loader.js:138:14)
    at Array.forEach (native)
    at _removeDecorators (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\@ngtools\webpack\src\loader.js:129:10)
    at Promise.resolve.then (D:\dev\Projects\SiteMobile\trese-sitemobile\node_modules\@ngtools\webpack\src\loader.js:292:33)
 @ ./src/$$_gendir/app/app.component.ngfactory.ts 12:0-51
 @ ./src/$$_gendir/app/app.module.ngfactory.ts
 @ D:/dev/Projects/SiteMobile/trese-sitemobile/src/main.ts
 @ multi ./src/main.ts

+1

@konrad-garus @mmiszy - well, I do not disagree with you two, but your comments are among many others who are having issues with basic installations. Either we need a way to expressly choose an option, or there is something suspect in the core build that is inhibiting development by others.

Not glad or sad or mad. Waiting for this issue to actually be re-opened and worked on, as it appears to be a recurring theme.

There's a good chance TypeScript is the future, and I'm quite sure there are many people interested in having TypeScript everywhere, without the extra build steps to JS. That's painful, inconvenient, lossy... and unnecessary.

Let's make the future happen, not force everyone back into the past.

I get the same error after upgrading from angular-cli 1.0.0-beta.19-3.
I've done all the steps in the migration guide and also copied the src folder into a new angular-cli 1.0.0.rc2 project, but still no luck.

I've also installed typings for socket.io and stuff like that.

ERROR in Cannot read property 'text' of undefined

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/simon/Nodes/project/src'
 @ ./src/main.ts 4:0-74
 @ multi webpack-dev-server/client?http://localhost:4200 ./src/main.t

Is there any way to get more debugging information to find the source of this problem?
Or any ideas how to solve that?

I've tried a couple of things recommended (like adding "typings.d.ts", "main", ... to tsconfig), but still no luck.

I've even checked if I use a property "text" somewhere in my Code, but no.

Any ideas?

@konrad-garus I hear what you are saying, and quite possibly TS is the way of the future, except..... I have seen this before - where one thing transposes/composes into another thing - with the latter being the actual code needed, in order to accomplish the job. And at the end of the day, whatever language was being composed to, ended up, once again, being what everyone used.

It is great that Microsoft launched TS in order to be a solid, stable platform that works well with Visual Studio, and they have been better at launching more open codebases than they were in the 90s.

Seeing the team at Mozilla being apparently committed to quicker, smaller release sets, it seems to me JS will continue to push forward, allowing us to develop robust applications without the need for transposing any code, unless we are in an environment or have a requirement set that demands it.

@SimonErich - I hope I am not offending when I ask this, but when you migrated, did you completely delete your node_modules directory, npm cache clear, then npm install, in order to re-install all necessary modules? There are times when I have followed the migration instructions and still had issues, until I cleared all modules, and cleared my cache.

I hate to be the bearer of bad news, but you may need to install your third party additions one at a time, until you find the error message.

The "text" error message has nothing to do with your personal code. It has to do with -cli tripping up on one of the third party packages, and how it was organized.

@metavurt Thank you very much for your answer.
I've tried npm cache clear and installing everything from scratch already, but always copied my files in there.

After your answer I decided to try to add the main parts of the application slowly and one by one and found the mistake.
It was indeed in my own code, but I the debugging message didn't make sense anyway.

For future reference:
My mistake was the wrong use of "export default".

I used to export an object like this:

export default {
   ...
};

This used to work with the older version of typescript and angular-cli.
I've changed the file to:

export const config = {
   ...
};

and now everything works.
I hope it helps someone.

Thank you for help @metavurt though

@SimonErich

My mistake was the wrong use of "export default".

I used to export an object like this:

export default {
...
};

That is 100% valid TypeScript code. incidentally it is also 100% valid JavaScript. If it causes the CLI to fail the CLI is wrong.

@SimonErich's workaround worked out for me. I was exporting my reducers as default functions. When I changed to using named functions instead, the project builds again.

So it works as a workaround. Thanx @SimonErich!

@SimonErich's trick worked for me too: I had to change

export default function (date: string): boolean { to
export default function validateDate(date: string): boolean {

and it's working now. It would be great to have the compilation fail earlier to have a clearer error message!

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._

Was this page helpful?
0 / 5 - 0 ratings