Answer the question
In order to leave comments, you need to log in
React: how to import from directory above src?
I am writing a website in React + TypeScript. Server Node.js + TypeScript
There are common interfaces, put in a separate folder. The directory structure is as follows:
- client
- common
- server
I created the client using react-scripts. My own problem is that I still couldn’t import interfaces from common into react normally.
Did npm run eject, disabled the ModuleScopePlugin,
but that didn't help, I suspect it just imports as a file and doesn't compile
. Maybe I'm doing something wrong. Now I'll go dig tsconfig.json
Answer the question
In order to leave comments, you need to log in
Throw in create-react-app, set up configs yourself, create a structure
-
src
-- common
-- client
-- server
anything related to the client will be used on the server, but anything related to the server will not be used on the client. So I would suggest this structure:
- src
-- app
-- server
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question