E
E
Evgeny2018-06-30 09:40:29
typescript
Evgeny, 2018-06-30 09:40:29

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
5b3725ae188c3027444671.png
. 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

1 answer(s)
A
Anubis, 2018-06-30
@Anubis

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 question

Ask a Question

731 491 924 answers to any question