-1

I just create my application from npm command, when i run the start script the application throws me that error.

2 Answers2

0

Please provide more context. If you're using typescript on your react project. You need to upgrade both react and react-dom declaration. npm install @types/react@latest and npm install @types/react-dom@latest

Jason
  • 1,680
  • 3
  • 13
  • 16
0

If you've recently updated past npm 8.5+ and using workspaces, you have two options.

Option A) If possible, just remove your package.json declaring your "workspaces" (and the package-lock.json). I had only 1 workspace so that was the easiest fix.

Option B) Update Jest so it can find your modules. I've observed NPM 8.11 will create a node_modules in the workspaces folder and in each project.

Specifically look at the moduleDirectories key below.

{
    verbose: true,
    testEnvironment: "jsdom",
    moduleFileExtensions: ["js", "jsx", "ts", "tsx"],
    moduleDirectories: [
        // Look in current directory node_modules
        path.resolve(__dirname, "node_modules"),
        // Look in parent workspace node_modules
        path.resolve(__dirname, "../node_modules"),
    ],
    moduleNameMapper: {
        ...moduleNameMapper,
        "\\.(jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.js",
        '\\.svg$': '<rootDir>/__mocks__/svgrMock.tsx',
        "\\.(css)$": "identity-obj-proxy"
    },
    transform: {
        "^.+\\.tsx?$": "ts-jest"
    },
};
SilbinaryWolf
  • 461
  • 4
  • 9