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
Can't build to parent outDir folder with 1.5.4 #8613
Set apps[0].outDir as "../dist" on .angular-cli.json
run ng b
Observed behavior
Only a error message: An asset cannot be written to a location outside the project.
Desired behavior
Build the project without problem.
Mention any other details that might be useful (optional)
We have tried to add allowOutsideDir to ours assets configuration on cli config, but doesn't work. Is this the expected behaviour? I don't found related information about it in de64b86 or #8122 :(
Same problem here.
I can't believe a major functionality of the CLI, "ng b", doesn't work after an update...
Downgrade to 1.5.3...
Reacted by jdenekat, Bernhard Reitinger, Benjamin Smith, Bernhard Windisch, Paulo, adrianOlmos, Tomasz Drabik, MaximeAnsquer, Rintu Mondal, Oleksandr Mohylka and 7 more
@hansl@filipesilva@rbluethl: This issue is occuring when the outdir in .angular-cli.json is outside the angular folder. (eg. "outDir": "../../bin/Debug/www")
// Prevent asset configurations from writing outside of the output path, except if the user// specify a configuration flag.// Also prevent writing outside the project path. That is not overridable.constfullOutputPath=path.resolve(buildOptions.outputPath,asset.output);if(!fullOutputPath.startsWith(projectRoot)){constmessage='An asset cannot be written to a location outside the project.';thrownewSilentError(message);}
I'm glad this is being fixed. I prevent my destination folder from being deleted by the CLI with the new "no-delete-output-path" option. Not a problem.
@djpysu They don't seem to want to fix it properly, so I have had to edit the angular/cli dist myself. It is odd how the team have been so slow on this, it is usually necessary to have a "common-assets" dir that several ui services can access such that you don't have the same "favicon.ico" or "logo.png" file copied X times.
What is interesting is that with the boolean flag set ("allowOutsideOutDir": true) on a particular asset, it normally makes ng build work but still notng serve. You can search the angular/cli code and actually see the line that makes the cli throw the error for ng serve. I simply commented out the one single line that calls throw() and presto, I got ng serve working as normal again with external assets.
Not sure why they implemented this to be frank. It isn't a security feature like they say because if a nefarious actor has compromised your system to such a degree that they can run your app straight off the bat, they sure can easily do what I just did and make ng serve work. I could be wrong though...
Yeah, I also thought that. I updated to 1.6.4 - not working, back to 1.5.3 - not working. Only with 1.4.1 is working for me. I think I'm doing something wrong.
This error is still occurring in 1.7.4. It's highly problematic for a project I'm working on since I have around 5GB worth of images to serve and placing them in the assets folder causes the ng serve to crash.
For anyone looking to fix it locally, edit ../node_modules/@angular/cli/models/webpack-configs/common.js. The code starts at line 99. I'm not going to make a pull request to fix it because I don't know if there is a legit reason for this functionality (although it seems odd to me and as others have mentioned, it's not really a security thing).
Reacted by Tudor Barbu and Dan Kilty
angular-automatic-lock-bot commented on Sep 8, 2019
Activity
rbluethl commentedon Nov 23, 2017
Same problem here.
I can't believe a major functionality of the CLI, "ng b", doesn't work after an update...
Downgrade to 1.5.3...
filipesilva commentedon Nov 24, 2017
@hansl can you have a look please?
p3root commentedon Nov 24, 2017
@hansl @filipesilva @rbluethl: This issue is occuring when the outdir in .angular-cli.json is outside the angular folder. (eg. "outDir": "../../bin/Debug/www")
rintum commentedon Nov 24, 2017
@hansl @filipesilva : Same issue here. Please fix the issue.
".angular-cli.json" Config
..."apps": [{"root": "src","outDir": "../web/src/main/resources/static","assets": [...On Build
>ng buildAn asset cannot be written to a location outside the project.xtazy commentedon Nov 24, 2017
Same problem, I'm using the outDir param to build outside my angular root folder.
dinerotah commentedon Nov 24, 2017
Same here
array42-zz commentedon Nov 24, 2017
Same here
gvart commentedon Nov 24, 2017
What flag is told about?
guilhermejcgois commentedon Nov 24, 2017
@gvart I think that the flag is
allowOutsideOutDirin the last section.miguelcaravantes commentedon Nov 24, 2017
Same problem
10 remaining items
michael-lang commentedon Nov 28, 2017
I'm glad this is being fixed. I prevent my destination folder from being deleted by the CLI with the new "no-delete-output-path" option. Not a problem.
djpysu commentedon Jan 16, 2018
Is there anybody who can help me understand how can I use the fix #8630 ?
samhuk commentedon Jan 16, 2018
@djpysu They don't seem to want to fix it properly, so I have had to edit the angular/cli dist myself. It is odd how the team have been so slow on this, it is usually necessary to have a "common-assets" dir that several ui services can access such that you don't have the same "favicon.ico" or "logo.png" file copied X times.
What is interesting is that with the boolean flag set (
"allowOutsideOutDir": true) on a particular asset, it normally makesng buildwork but still notng serve. You can search the angular/cli code and actually see the line that makes the cli throw the error forng serve. I simply commented out the one single line that callsthrow()and presto, I got ng serve working as normal again with external assets.Not sure why they implemented this to be frank. It isn't a security feature like they say because if a nefarious actor has compromised your system to such a degree that they can run your app straight off the bat, they sure can easily do what I just did and make
ng servework. I could be wrong though...guilhermejcgois commentedon Jan 16, 2018
@djpysu the fix was released with v1.5.5... I personally doesn't remember to do some changes in my configs to get work... Which version r u using?
djpysu commentedon Jan 16, 2018
Yeah, I also thought that. I updated to 1.6.4 - not working, back to 1.5.3 - not working. Only with 1.4.1 is working for me. I think I'm doing something wrong.
guilhermejcgois commentedon Jan 16, 2018
can u share ur config and error message?
djpysu commentedon Jan 16, 2018
Same error message like everybody: An asset cannot be written to a location outside the project.
From angular-cli.json
package.json
trendzetter commentedon Jan 24, 2018
Same issue with 1.6.3 and 1.6.5 when running 'ng build'
An asset cannot be written to a location outside the project.Sanafan commentedon Feb 2, 2018
when will this be fixed ...
trendzetter commentedon Feb 16, 2018
@Sanafan You could look into it. It's marked as an easy to fix regression
shanemcgarry commentedon Apr 27, 2018
This error is still occurring in 1.7.4. It's highly problematic for a project I'm working on since I have around 5GB worth of images to serve and placing them in the assets folder causes the ng serve to crash.
For anyone looking to fix it locally, edit ../node_modules/@angular/cli/models/webpack-configs/common.js. The code starts at line 99. I'm not going to make a pull request to fix it because I don't know if there is a legit reason for this functionality (although it seems odd to me and as others have mentioned, it's not really a security thing).
angular-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.