NG serve can't find ssl files

Viewed 784

I try to run default ASP.NET 6 angular project template and unfortunately npm start fails by exception

"start:windows": "ng serve --port 8001 --ssl --ssl-cert %APPDATA%\\ASP.NET\\https\\${npm_package_name}.pem --ssl-key %APPDATA%\\ASP.NET\\https\\${npm_package_name.key}",

An unhandled exception occurred: ENOENT: no such file or directory, open 'C:\Users\ffres\Documents\GitHub\NFTMarketPlace\MarketPlace\MarketPlace\ClientApp\%APPDATA%\ASP.NET\https\${npm_package_name}.key'

But weirdly if i remove --ssl-cert parameter, it works fine. Surely i need -ssl-cert parameter as well.

"start:windows": "ng serve --port 8001 --ssl --ssl-key %APPDATA%\\ASP.NET\\https\\${npm_package_name}.key"

I can't use absolute full path in here so i need to use AppData and npm_package_name variables in path.

Can someone help me ?

1 Answers

This is an issue if your windows account has a space in the name. It's been merged into the main repo but I don't believe the template has been updated.

Github

Change your start to this

"ng serve --ssl --ssl-cert \"%APPDATA%\\ASP.NET\\https\\%npm_package_name%.pem\" --ssl-key \"%APPDATA%\\ASP.NET\\https\\%npm_package_name%.key\""

We wrap the path in quotes in case there's a space. Notice the double quotes on the end as well.

Related