Webpack + React + TypeScript: Module not found … in … node_modules/react/

前端 未结 2 1015
抹茶落季
抹茶落季 2020-12-11 00:10

I\'m trying to put together a very basic project with React, TypeScript and Webpack. When I compile I get the following errors from the react folder in n

相关标签:
2条回答
  • 2020-12-11 00:17

    Webpack is not resolving .js files. Add this to your webpack.config.js.

    resolve: {
        extensions: [".ts", ".tsx", ".js", ".jsx"]
    },
    

    Here is the tsconfig.json I used to run your example.

    {
      "compilerOptions": {
        "jsx": "react",
        "lib": ["es6", "dom"],
        "rootDir": "src",
        "module": "commonjs",
        "target": "es5",
        "sourceMap": true,
        "moduleResolution": "node",
        "noImplicitReturns": true,
        "noImplicitThis": true,
        "noImplicitAny": true,
        "strictNullChecks": true
      },
      "include": [
        "./src"
      ],
      "exclude": [
        "node_modules",
        "build"
      ]
    }
    
    0 讨论(0)
  • 2020-12-11 00:30

    In VSCode, check Deno Extension and set it Enable(Workspace)

    0 讨论(0)
提交回复
热议问题