I want to create a nx workspace for plain react apps.
Create Workspace
npx create-nx-workspace@latest # installs 15.2.1
# style: package-based
# distributed caching: NO
Install react-package
npm install -D @nrwl/react
Create js react app
npx nx g @nrwl/react:app my-new-app --js
But if I try to start the app
npx nx serve my-new-app
I get following error:
Why is the module typescript
needed in a plain js app? Or why is it not installed when it is needed?
Thanks
I've had this as well with
@nrwl/js
in a package based monorepo setup usingcreate-nx-workspace
, where I tried to run@nrwl/js:init
but it seems to do nothing, and then@nrwl/js:lib
gives me the errorCannot find tsconfig.base.json
.If I instead use
create-nx-workspace
to choose an integrated monorepo setup, and choose to use thets
option for an empty monorepo with the JS/TS plugin preinstalled, then it is setup correctly.Perhaps generating the repo with the integrated react setup can help you pin down what's missing for your package based setup.
Apart from that, perhaps you could check the Nx Github to see if there's any issue relevant, e.g. the one below:
To me it seems like a bug, or at least, if its not being used in the intended way, its a user experience issue that may they need to improve - perhaps its documented on the website, but for beginners, just using
create-nx-workspace
should be the easiest way to get started.Update: I see that the Package-Based Repo Tutorial actually does mention to install TypeScript manually, but my point above still remains -
create-nx-workspace
should do the work I need to create a workspace, TypeScript seems required for most if not all workspaces, so having it as a manual step seems to defeat the point.