ASP.NET Core 2.1 fails with react / CRA template on start
I created a new ASP.NET Core 2.1 app (on Linux x64 / Ubuntu) and am now trying to get it to work in Development mode. I used the react / CRA template following this guide: https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-run?tabs=netcore2x
I got the following error when startintg:
aj@kennedy ~/romp $ export ASPNETCORE_ENVIRONMENT=Development
aj@kennedy ~/romp $ dotnet run
info: Microsoft.AspNetCore.DataProtection.KeyManagement.XmlKeyManager[0]
User profile is available. Using '/home/aj/.aspnet/DataProtection-Keys' as key repository; keys will not be encrypted at rest.
info: Microsoft.AspNetCore.SpaServices[0]
Starting create-react-app server on port 41269...
Hosting environment: Development
Content root path: /home/aj/romp
Now listening on: http://localhost:5000
Application started. Press Ctrl+C to shut down.
info: Microsoft.AspNetCore.SpaServices[0]
> [email protected] start /home/aj/romp/ClientApp
> rimraf ./build && react-scripts start
Starting the development server...
fail: Microsoft.AspNetCore.SpaServices[0]
events.js:165
npmfail: Microsoft.AspNetCore.SpaServices[0]
throw er; // Unhandled 'error' event
^
Error: watch /home/aj/romp/ClientApp/public ENOSPC
at FSWatcher.start (fs.js:1402:19)
at Object.fs.watch (fs.js:1428:11)
at createFsWatchInstance (/home/aj/romp/ClientApp/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:37:15)
at setFsWatchListener (/home/aj/romp/ClientApp/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:80:15)
at FSWatcher.NodeFsHandler._watchWithNodeFs (/home/aj/romp/ClientApp/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:228:14)
at FSWatcher.NodeFsHandler._handleDir (/home/aj/romp/ClientApp/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:407:19)
at FSWatcher.<anonymous> (/home/aj/romp/ClientApp/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:455:19)
at FSWatcher.<anonymous> (/home/aj/romp/ClientApp/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:460:16)
at FSReqWrap.oncomplete (fs.js:171:5)
Emitted 'error' event at:
at FSWatcher._handleError (/home/aj/romp/ClientApp/node_modules/webpack-dev-server/node_modules/chokidar/index.js:257:10)
at createFsWatchInstance (/home/aj/romp/ClientApp/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:39:5)
at setFsWatchListener (/home/aj/romp/ClientApp/node_modules/webpack-dev-server/node_modules/chokidar/lib/nodefs-handler.js:80:15)
[... lines matching original stack trace ...]
at FSReqWrap.oncomplete (fs.js:171:5)
npm ERR! code ELIFECYCLE
fail: Microsoft.AspNetCore.SpaServices[0]
npm ERR! errno 1
npmfail: Microsoft.AspNetCore.SpaServices[0]
npm ERR! [email protected] start: `rimraf ./build && react-scripts start`
npm ERR!fail: Microsoft.AspNetCore.SpaServices[0]
npm ERR! Exit status 1
fail: Microsoft.AspNetCore.SpaServices[0]
npm ERR!
npm ERR! Failed at the [email protected] start script.
fail: Microsoft.AspNetCore.SpaServices[0]
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
fail: Microsoft.AspNetCore.SpaServices[0]
npm ERR! A complete log of this run can be found in:
^CApplication is shutting down...```
OK, fine, so rimraf and react-scripts npms were missing. I installed them manually + globally using npm
install rimraf react-scripts --global
Issue persisted.
I then read somewhere there is a potential issue with number of open filehandles on Linux. The following helped:
```aj@kennedy ~/romp $ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p```
And then it appears to compile + react the React midldleware. Is there an issue on Linux?
I had the same issue and had to update NODE and NPM and use standalone instead of bundled with VS2017.
This URL can help you with understanding the NPM and NODE kitchen for WIN https://github.com/npm/npm/wiki/Troubleshooting
Yup download node and install it. Then go into Tools Options and then Exyernal Web. There you can add a reference to use node in c:\program files\node (assuming default install location). With this done RESTART VISUAL STUDIO. Then open the PM console (Type PM in search) and type node -v you want version 8 or so..
This issue was moved to https://github.com/aspnet/JavaScriptServices/issues/1718
@ajensenwaud :+1:
I then read somewhere there is a potential issue with number of open filehandles on Linux. The following helped: $ echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
I'm having this exact issue. I'm not sure where this conversation got moved to though as I don't understand what "aspnet/JavaScriptServices#1718" is referencing.
nm...found it https://github.com/aspnet/AspNetCore/issues/5217
I updated the link in above comment https://github.com/dotnet/core/issues/1594#issuecomment-404273623 to point to the original URL, which redirects to the new one you listed.