Repository navigation
"ng serve" gives compilation error #5034
Description
OS: Windows 10
Versions :
@angular/cli: 1.0.0-rc.0
node: 6.10.0
os: win32 x64
Reproduction steps:
It's an app that is fully created with angular-CLI.
- "ng serve" gives an error but compiles successfully the second time if made any changes to any of the files.
The log given by the failure.
`ng serve
** NG Live Development Server is running on http://localhost:4200 **
Hash: 9fbd9d1c055b9f5a4fca
Time: 13195ms
chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 153 kB {5} [initial] [rendered]
chunk {1} styles.bundle.js, styles.bundle.js.map (styles) 198 kB {5} [initial] [rendered]
chunk {2} main.bundle.js, main.bundle.js.map (main) 17.5 kB {4} [initial] [rendered]
chunk {3} scripts.bundle.js, scripts.bundle.js.map (scripts) 434 kB {5} [initial] [rendered]
chunk {4} vendor.bundle.js, vendor.bundle.js.map (vendor) 3.13 MB [initial] [rendered]
chunk {5} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
ERROR in Error encountered resolving symbol values statically. Reference to a local (non-exported) symbol 'routes'. Consider exporting the symbol (position 5:7 in the original .ts file), resolving symbol AppRoutingModule in D:/TesTracker/src/app/app-routing.module.ts
webpack: Failed to compile.
webpack: Compiling...
Hash: 9fbd9d1c055b9f5a4fca
Time: 2302ms
chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 153 kB {5} [initial]
chunk {1} styles.bundle.js, styles.bundle.js.map (styles) 198 kB {5} [initial]
chunk {2} main.bundle.js, main.bundle.js.map (main) 17.5 kB {4} [initial]
chunk {3} scripts.bundle.js, scripts.bundle.js.map (scripts) 434 kB {5} [initial]
chunk {4} vendor.bundle.js, vendor.bundle.js.map (vendor) 3.13 MB [initial]
chunk {5} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry]
webpack: Compiled successfully.`
Mention any other details that might be useful.
The issue arises when I create child routes and use loadchildren from the calling router module
Note: I have made no changes when it compiled successfully the second time. I just re-saved a file just to make it recompile and it does the work.
Update
I figured out the exact issue. The issue is with lazy loading. When I use following route array with PagesModule in imports
[{ path: '', children: [ { path: 'pages', loadChildren: () => PagesModule }, { path: '', redirectTo: 'pages', pathMatch: 'full' } ] }]
But works perfectly when I use the following routes array:
[ { path: '', children: [ { path: 'pages', loadChildren: './pages/pages.module#PagesModule' }, { path: '', redirectTo: 'pages', pathMatch: 'full' } ] } ]
Activity
marcelino-m commentedon Feb 27, 2017
I have same issue in linux, but this arises when I use "typeRoots" option in tsconfi.app.json with local type definitions file.
Randomly fails with the message:
vladotesanovic commentedon Feb 27, 2017
@marcelino-m
Don't use
typeRootsanymore, here is documentation how to use custom typings:Easiest for you is to create src/typings.d.ts file than in that file to import your custom types:
src/typings.d.ts
akhilbojedla commentedon Feb 28, 2017
I figured out the exact issue. The issue is with lazy loading. When I use following route array with PagesModule in imports
[{ path: '', children: [ { path: 'pages', loadChildren: () => PagesModule }, { path: '', redirectTo: 'pages', pathMatch: 'full' } ] }]But works perfectly when I use the following routes array:
[ { path: '', children: [ { path: 'pages', loadChildren: './pages/pages.module#PagesModule' }, { path: '', redirectTo: 'pages', pathMatch: 'full' } ] } ]marcelino-m commentedon Mar 4, 2017
@vladotesanovic
Thanks for the help!.
doggy8088 commentedon Mar 4, 2017
@vladotesanovic Is there any reason why you said
Don't use typeRoots anymore?marcelino-m commentedon Mar 4, 2017
@doggy8088
Here the docs, https://github.com/angular/angular-cli/wiki/stories-third-party-lib
doggy8088 commentedon Mar 4, 2017
@marcelino-m Thanks.
In my testing, the
npm startunable to compile all my TypeScript file correctly. It just can't include@typescorrectly.Here is the steps to repro the problem.
ng new demo0304 --ng4cd demo0304npm install --save-dev @types/jquerysrc/app/app.component.ts. Add the following line:src/tsconfig.app.jsonWhen you execute
npm start, you will get this error:If I run
tsc -p src\tsconfig.app.json, no problem at all.In my Visual Studio Code, no problem at all.
Is that an issue?
marcelino-m commentedon Mar 4, 2017
@doggy8088 Hi,
I think you are missing install jquery. You have just instaled @types/jquery (types definition for jquery)
not jquery itself.
Here what I done:
Edit app.component.ts (import jquery module)
So run
Run Ok.
if you wish now you cant install @types/jquery
Cheers!
doggy8088 commentedon Mar 5, 2017
@marcelino-m Yes, you are right. It do works using your way to setup jquery.
In my case, my jquery has already been loaded in the index.html file. I don't want to load it again and bundled with my Angular app. So there is long time, I use jquery by this way which is load
@types/jqueryonly in my app but full jquery library.As I mentioned in my original question, my current setup can work as expected in my Visual Studio Code and using tsc standalone. It only show up errors when I using
ng serve. I don't know why. Can you tell?doggy8088 commentedon Mar 7, 2017
Known issue & PR here: #5251
filipesilva commentedon Mar 14, 2017
Heya, errors like
Error encountered resolving symbol values staticallymean that there has been some problem in statically analyzing your app.The CLI always runs statical analysis on code to ensure it will run when compiled with AOT. This may cause a lot of static analysis errors to surface when importing your project into the CLI, or upgrading for older versions where we didn't run this kind of analysis.
A good resource on how to to debug these errors is https://github.com/rangle/angular-2-aot-sandbox#aot-dos-and-donts.
The other issues brought up seem to be completely unrelated to the original one. Please open new issues and fill out the issue template for them.
angular-automatic-lock-bot commentedon Sep 6, 2019
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.