angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Updated to angular/cli:^1.6.8 - Error during template compile of 'PlatformRef'

Open michaelb-01 opened this issue 8 years ago • 18 comments

Versions

<!--
Output from: `ng --version`.
If nothing, output from: `node --version` and `npm --version`.
  Windows (7/8/10). Linux (incl. distribution). macOS (El Capitan? Sierra?)
-->

Angular CLI: 1.6.8 (e) Node: 8.9.1 OS: darwin x64 Angular: 5.2.4 ... animations, common, compiler, compiler-cli, core, forms ... http, language-service, platform-browser ... platform-browser-dynamic, router

@angular/cdk: 5.2.0
@angular/cli: 1.6.8
@angular/material: 5.2.0
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.8
@schematics/angular: 0.1.17
typescript-extends: 1.0.1
typescript: 2.4.2
webpack-concat-plugin: 1.4.0
webpack-dev-server: 2.11.1
webpack: 3.10.0

Repro steps

  • Step 1
  • Step 2
  • Step 3

Observed behavior

<!-- Normally this includes a stack trace and some more information. -->
ERROR in Error during template compile of 'PlatformRef'
  Function calls are not supported in decorators but 'ɵmakeDecorator' was called in 'Injectable'
    'Injectable' calls 'ɵmakeDecorator'.

Desired behavior

Mention any other details that might be useful (optional)

michaelb-01 avatar Feb 09 '18 08:02 michaelb-01

Same error... was working yesterday.....

accilies avatar Feb 09 '18 11:02 accilies

Anyone know how to fix this? Or is there a different version I can roll back to?

michaelb-01 avatar Feb 10 '18 08:02 michaelb-01

Please provide the steps you followed to get to this error, or better yet provide a repository that shows this error.

Brocco avatar Feb 12 '18 15:02 Brocco

I am getting the same thing, on my own very simple module which provides a simple config value.

ERROR in Error during template compile of 'MyCoPlatformModule' Function calls are not supported in decorators but 'MyCoComponentsModule' was called.

httpete avatar Feb 14 '18 18:02 httpete

FIXED.

For me, I was importing a file out of my project config... changing that fixed the error... Finally..

accilies avatar Feb 14 '18 19:02 accilies

This is my tsconfig - is that what you mean @accilies ?

{ "version": "2.5.3", "compilerOptions": { "module": "commonjs", "target": "ES5", "emitDecoratorMetadata": true, "experimentalDecorators": true, "moduleResolution": "node", "baseUrl": "./", "paths": { "@angular/*": [ "node_modules/@angular/*" ], "@uirouter/*": [ "node_modules/@uirouter/*" ] }, "lib": [ "es2017", "dom" ] }, "include": [ "src/**/*.ts" ], "exclude": [ "test.ts", "**/*.spec.ts" ] }

httpete avatar Feb 14 '18 20:02 httpete

I am hitting the same issue. Simple recreation steps:

  1. Create 2 new Angular projects, project1 and project2
  2. Reference a component in project2 from a module in project1
  3. In project1, ng build --prod

This can be tested simply with this shell script:

mkdir prod-build-error
cd prod-build-error
ng new project1
ng new project2
cd project1/src/app
sed 's|./app.component|../../../project2/src/app/app.component|' <app.module.ts >app.module2.ts
rm app.module.ts
mv app.module2.ts app.module.ts
cd ../..
ng build --prod

Result:

ERROR in ../../project2/src/app/app.component.ts(3,2): Error during template compile of 'AppComponent'
  Function calls are not supported in decorators but 'ɵmakeDecorator' was called in 'Component'
    'Component' calls 'ɵmakeDecorator'.

pcroc avatar Apr 04 '18 13:04 pcroc

+1 on what @pcroc shows.

mderoche avatar Apr 10 '18 16:04 mderoche

Getting same error here, when I tried to run cmd: ng build --prod. will not get this if I don't build in production mode.

Log stack as follow:

Date: 2018-04-11T20:00:47.740Z Hash: e2a911aa7287d5340be6 Time: 10887ms chunk {scripts} scripts..bundle.js (scripts) 342 kB [initial] [rendered] chunk {0} styles..bundle.css (styles) 716 kB [initial] [rendered] chunk {1} polyfills..bundle.js (polyfills) 84 bytes [initial] [rendered] chunk {2} main..bundle.js (main) 84 bytes [initial] [rendered] chunk {3} inline.*************.bundle.js (inline) 796 bytes [entry] [rendered]

ERROR in Error during template compile of 'PlatformRef' Function calls are not supported in decorators but 'ɵmakeDecorator' was called in 'Injectable' 'Injectable' calls 'ɵmakeDecorator'.

Letheros avatar Apr 11 '18 20:04 Letheros

I managed to figure out what was causing this error in my case. (Seems like this could be caused by many things.)

I have an application that uses a library, where I develop both of them, and the library is symlinked to the application. The library would import { ... } from '@angular/core', but was trying to pull @angular/core from the node_modules local to that library instead of the node_modules local to the application.

Adding the Angular modules to the paths in tsconfig.app.json solved the issue. It'll point all of the Angular imports to the node_modules in the application instead of the node_modules in the library.

  "compilerOptions": {
    "paths": {
        "@angular/*": [ "../node_modules/@angular/*"]
    }
  }

mderoche avatar Apr 11 '18 20:04 mderoche

@accilies What do you mean by "exporting a file out my project configuration"?

rtm avatar Jun 04 '18 13:06 rtm

@mderoche But I thought some recent version of TS explicitly solved that problem of "same-but-different" libraries. By the way, did you experiment with --preserve-symlinks?

rtm avatar Jun 04 '18 13:06 rtm

This error is occurring to me with ^6.0.0 versions.

ERROR in ../@nims/ngutils/lib/collapsible-fieldset/collapsible-fieldset.component.ts(13,2): Error during template compile of 'CollapsibleFieldsetComponent' Function calls are not supported in decorators but 'ɵmakeDecorator' was called in 'Component' 'Component' calls 'ɵmakeDecorator'.

rtm avatar Jun 04 '18 13:06 rtm

@mderoche that didnt work for me

i'm trying to create angular-elements element for one component of a bigger app in a different dir.

`import {NgModule,Injector} from '@angular/core'; import {createCustomElement} from '@angular/elements'; import {BrowserModule} from '@angular/platform-browser';

import {SideMenuComponent} from '../../webapp-src/components/app/side-menu.component';

@NgModule({ imports: [BrowserModule], declarations: [SideMenuComponent], entryComponents: [SideMenuComponent] }) export class AppModule {

constructor (private injector: Injector) { const customElement = createCustomElement(SideMenuComponent, {injector}); customElements.define('side-menu', customElement); }

ngDoBootstrap () { }

}`

ERROR in ../../webapp-src/components/app/side-menu.component.ts(16,2): Error during template compile of 'SideMenuComponent' Function calls are not supported in decorators but 'ɵmakeDecorator' was called in 'Component' 'Component' calls 'ɵmakeDecorator'.

liorwohl avatar Aug 13 '18 07:08 liorwohl

ok it did work, just needed to change it to

"baseUrl": "./", "paths": { "@angular/": ["node_modules/@angular/"] },

liorwohl avatar Aug 13 '18 07:08 liorwohl

This usually happens when using npm link

alan-agius4 avatar Sep 18 '18 16:09 alan-agius4

I resolve this problem by change my source code that import component, module with the relative paths to absolute paths.

sombatsombat avatar Jan 28 '19 21:01 sombatsombat

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.