我使用 Node.js + Typescript 和 React+ Typescript 构建全栈应用程序。文件夹结构:
App
-node_modules //server part's dependencies
-build //includes compiled server code
-src
-server
-client
-node_modules //client part's dependencies
tsconfig.json //created by 'create-react-app'
package.json //created by 'create-react-app'
tsconfig.json
tslint.json
package.json // includes config for server compiling and running
所以,当我执行命令tsc && node build/www
服务器启动时。
但是如果我想用 command 构建 react 包react-scripts-ts start
,我会得到不属于 react 项目的错误。例如:
Failed to compile.
~/projects/App/node_modules/@types/graphql/execution/execute.d.ts
(1,44): Cannot find module '../error'.
为什么 react-scripts-ts 在 non-react 文件夹中查找依赖项?