macでもコマンドベースだとSPAがちゃんと動きます。以下の通り。
dotnet new angular -o angularTest npm i webpack dotnet restore dotnet build dotnet run
これで動くのでvscodeでデバッグしたら以下のエラー。。
意味不明なエラーが出た、ubuntuでは動いたのに。。
発生したコード
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions { HotModuleReplacement = true });
例外メッセージ
例外が発生しました: CLR/System.AggregateException An exception of type 'System.AggregateException' occurred in System.Private.CoreLib.dll but was not handled in user code: 'One or more errors occurred.' Inner exceptions found, see $exception in variables window for more details. Innermost exception System.ComponentModel.Win32Exception : No such file or directory at System.Diagnostics.Process.ResolvePath(String filename) at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo) at System.Diagnostics.Process.Start() at System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.LaunchNodeProcess(ProcessStartInfo startInfo)
これは、angular(フロントJS)をIISで動かそうとしてるのでファイルがねーぞって言われているエラーです。
nodeの環境変数を設定してるのに!
いい記事を発見。
GUI applications on the Mac do not use inherit any environment variables that are defined for the terminal neither do they run any bash profile scripts. So option 2 is probably the best option.
VS Mac adds the following two paths to its PATH environment variable.
/usr/local/bin
/Library/Frameworks/Mono.framework/Commands
I do not believe there are any plans to have VS Mac somehow execute the bash profile script.
VS2017 for Mac - UseWebpackDevMiddleware crash on application start - Developer Community
macのGUIアプリケーションは.bash_profileに設定した環境変数を継承しません。なのでアプリ側にnodeのPATHを設定しないとnodeがないと言われちゃうみたいです。これはmacの仕様なので諦めてね♡ってことみたい。
VSCodeではlaunch.jsonに記載すればおっけいです。vscodeの環境変数は「env」なのでそこに設定してあげましょう。
"env": { ... "PATH": "/Users/{自分の名前}/.nodebrew/current/bin" // 参考なので設置したパス },
で実行。
macでも環境できてよかったわー。