You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ng build --prod unable to process symbolic links #5098
@angular/cli: 1.0.0-rc.0
node: 7.4.0
os: linux x64
I am working on two angular-cli projects (frontend and backend). As they share many components, services etc, I created a folder "actual-common" and put a symbolic link "common" under the src folder of each project. This worked well until I performed an ng build using the --prod option, at which point every shared item gives the following message.
ERROR in ../actual-common/modules/auth0/logout/logout.component.ts
Module build failed: TypeError: Cannot read property 'text' of undefined
at Object.getTokenPosOfNode (/home/Angular/frontend/node_modules/typescript/lib/typescript.js:6768:71)
at IdentifierObject.TokenOrIdentifierObject.getStart (/home/Angular/frontend/node_modules/typescript/lib/typescript.js:80500:23)
at IdentifierObject.TokenOrIdentifierObject.getText (/home/Angular/frontend/node_modules/typescript/lib/typescript.js:80521:77)
at refactor.findAstNodes.filter (/home/Angular/frontend/node_modules/@ngtools/webpack/src/loader.js:139:44)
at Array.filter (native)
at refactor.findAstNodes.forEach.node (/home/Angular/frontend/node_modules/@ngtools/webpack/src/loader.js:138:14)
at Array.forEach (native)
at _removeDecorators (/home/Angular/frontend/node_modules/@ngtools/webpack/src/loader.js:129:10)
at Promise.resolve.then (/home/Angular/frontend/node_modules/@ngtools/webpack/src/loader.js:292:33)
@ ./src/$$_gendir/app/app.module.ngfactory.ts 81:0-79
@ ./src/main.ts
@ multi ./src/main.ts
I noted that the error refers to my absolute path "actual-common", so I presume it is a webpack issue similar to webpack/webpack#1643 I also note that a custom webpack configuration is not available using Angular-Cli, so the workaround described on the issue is not available to me.
My workaround was to clone the project and replace the "common" symlink with the actual files.
(Is there a better way to share code between local projects?)
It looks like when I run ng build --prod inside a location thats a symlink, all of the nodes coming back from this code have an undefined parent.
If I run the command inside the actual directory, the parents are correctly set.
EDIT:
I can actually fix the issue if I pass the sourceFile argument into getStart() in the typescript compiler here, but I don't think that's actually a fix. Not sure why the parents are undefined inside the symlink.
So the typescript compiler's currentDirectory is the symlink location, but the paths getting passed into getSourceFile are resolved paths(so the actual location on disk), which I guess is throwing the typescript compiler out of whack, so it's just returning undefined.
@MortimerCat You would want to use AOT in a production environment. It compiles your html/css files into the internal angular components. If you skip this step, it ends up happening in the browser which will increase page load time.
I'm getting a similar issue on Windows 7 which appears related to routing, but I'm not using symlinks. But I get the error only in IE11, not Chrome. I'm using all the recommended IE polyfills from polyfills.js. Angular 4.0.0, CLI 1.0.0.
I was trying to create a repro but haven't narrowed it down to something small yet. Again, only get the error with ng serve --prod (or ng build); error goes away with --aot false.
"Uncaught (in promise): TypeError: Unable to get property 'initialNavigation' of undefined or null reference
TypeError: Unable to get property 'initialNavigation' of undefined or null reference
at t.prototype.isLegacyDisabled (http://localhost:4200/vendor.35a56695c585013b7d07.bundle.js:407:2550)
at Anonymous function (http://localhost:4200/vendor.35a56695c585013b7d07.bundle.js:407:1510)
at t.prototype.invoke (http://localhost:4200/polyfills.1b67348a0bf296656461.bundle.js:36:9782)
at onInvoke (http://localhost:4200/vendor.35a56695c585013b7d07.bundle.js:316:8090)
at t.prototype.invoke (http://localhost:4200/polyfills.1b67348a0bf296656461.bundle.js:36:9782)
at n.prototype.run (http://localhost:4200/polyfills.1b67348a0bf296656461.bundle.js:36:5065)
at Anonymous function (http://localhost:4200/polyfills.1b67348a0bf296656461.bundle.js:36:2119)
at t.prototype.invokeTask (http://localhost:4200/polyfills.1b67348a0bf296656461.bundle.js:36:10439)
at onInvokeTask (http://localhost:4200/vendor.35"
Reacted by jasedwards, Jiří Balcar, Vishal Srinivasan and Nikita Bakaev
A way to look for the problematic code: Find the Node primitive (fs.whatever) for resolving symlinks - this is the thing we don't want CLI or anything it calls, to use. Add a "throw" there. Look at stack trace. Use that to find wherever in CLI it gets called. Then work through how CLI calls libraries to avoid this happening.
I was having a similar issue with accessing third party libraries, disabling aot resolved this issue and the prod build was a similar size to that that is was when using aot.
Hi,
How do you guys use this flag when running ng serve? it doesn't seem to have this flag, so how do you start the server while preserving symbolic links?
ng build --preserve-symlinks --watch, does not allow angular-cli to build my project with symlinked files inside node_modules. My issue is not resolved. I cannot develop locally without npm link.
Reacted by seanlandsman, Tobyn Baugher, Corbin Crutchley, LoveenDyall and El Pupi
Activity
kipy-be commentedon Feb 28, 2017
+1
Same on Windows 10
But the symlinks are correctly resolved with "ng serve"
mitosandov commentedon Mar 1, 2017
+1
stephen-moyer commentedon Mar 1, 2017
Getting this too, on Windows though.
It looks like when I run
ng build --prodinside a location thats a symlink, all of the nodes coming back from this code have an undefined parent.If I run the command inside the actual directory, the parents are correctly set.
EDIT:
I can actually fix the issue if I pass the sourceFile argument into getStart() in the typescript compiler here, but I don't think that's actually a fix. Not sure why the parents are undefined inside the symlink.
After more debugging, program.getSourceFile(fileName) is coming back undefined when inside the symlink directory.
So the typescript compiler's currentDirectory is the symlink location, but the paths getting passed into getSourceFile are resolved paths(so the actual location on disk), which I guess is throwing the typescript compiler out of whack, so it's just returning undefined.
kipy-be commentedon Mar 5, 2017
I've noticed that AOT is now enabled by default with the
--prodflag.I tried disabling it to see what happens, and... It seems to work.
So, both
ng build --prod --aot falseng serve --prod --aot falseare working with symlink resolution.
The issue is aot related.
stephen-moyer commentedon Mar 6, 2017
@MortimerCat You would want to use AOT in a production environment. It compiles your html/css files into the internal angular components. If you skip this step, it ends up happening in the browser which will increase page load time.
filipesilva commentedon Mar 14, 2017
Sounds like a bug. Thanks for reporting it.
sangecz commentedon Mar 21, 2017
Same issue on latest tooling.
How does it looks like, when can we expect AOT to be working again? Thx.
irontoby commentedon Mar 30, 2017
I'm getting a similar issue on Windows 7 which appears related to routing, but I'm not using symlinks. But I get the error only in IE11, not Chrome. I'm using all the recommended IE polyfills from
polyfills.js. Angular 4.0.0, CLI 1.0.0.I was trying to create a repro but haven't narrowed it down to something small yet. Again, only get the error with
ng serve --prod(orng build); error goes away with--aot false.kylecordes commentedon May 22, 2017
A way to look for the problematic code: Find the Node primitive (fs.whatever) for resolving symlinks - this is the thing we don't want CLI or anything it calls, to use. Add a "throw" there. Look at stack trace. Use that to find wherever in CLI it gets called. Then work through how CLI calls libraries to avoid this happening.
5 remaining items
samrantmedia commentedon Jul 17, 2017
I was having a similar issue with accessing third party libraries, disabling aot resolved this issue and the prod build was a similar size to that that is was when using aot.
filipesilva commentedon Jul 24, 2017
We have made a few changes to how we process symlinks, and think this issue was fixed in one of them. Closing then.
nirzamir commentedon Sep 4, 2017
Hi,
How do you guys use this flag when running ng serve? it doesn't seem to have this flag, so how do you start the server while preserving symbolic links?
SebastianSchenk commentedon Sep 24, 2017
According to the source file of the serve command (here) there is no
--preserve-symlinksfor the serve command.ORESoftware commentedon Feb 14, 2018
ng build --preserve-symlinks --watch, does not allow angular-cli to build my project with symlinked files inside node_modules. My issue is not resolved. I cannot develop locally withoutnpm link.liujingbreak commentedon Nov 6, 2018
So, Angular + symlink issues add up as following?
--aotmust be used with--preserve-symblinks--aotis on, due to Webpack's watchpack issue, watch symlink directories might malfunctionangular-automatic-lock-bot commentedon Sep 8, 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.