【问题标题】:react-scripts-ts looks for dependencies in all folders and throws error on buildreact-scripts-ts 在所有文件夹中查找依赖项并在构建时抛出错误
【发布时间】:2018-04-27 05:34:58
【问题描述】:

我使用 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 时,服务器启动。

但如果我想使用命令react-scripts-ts start 构建反应包,我会收到不属于反应项目的错误。例如:

Failed to compile.
~/projects/App/node_modules/@types/graphql/execution/execute.d.ts
(1,44): Cannot find module '../error'.

为什么 react-scripts-ts 会在 non-react 文件夹中查找依赖项?

【问题讨论】:

    标签: node.js reactjs typescript single-page-application react-fullstack


    【解决方案1】:

    只需将 client/tsconfig.json 添加到 compilerOptions 下一条规则: "skipLibCheck": true

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-03-31
      • 1970-01-01
      • 1970-01-01
      • 2020-11-05
      • 1970-01-01
      • 2013-04-14
      • 2021-12-25
      • 1970-01-01
      相关资源
      最近更新 更多