task-management-frontend icon indicating copy to clipboard operation
task-management-frontend copied to clipboard

when fork the front end app, it runs, when i start the back...i get error TS2688:Cannot find type definition file for 'react-dom'

Open hmiiro opened this issue 5 years ago • 2 comments

when fork the front end app, it runs, when i start the back...i get error TS2688:Cannot find type definition file for 'react-dom'

hmiiro avatar Sep 24 '19 23:09 hmiiro

Did you install the type? npm install @types/node --save-dev and in tsconfig file add: { "compilerOptions": { "types": ["node"] } }

saritvakrat avatar Sep 30 '19 17:09 saritvakrat

Yeah I get the same error, the solution above didn't work.

If I try to start NestJS (npm start from the NestJS folder) I get the same import error. The issue is on this file: task-management-frontend/node_modules/react-scripts/lib/react-app.d.ts

TO FIX I added this at the start of the react-app.d.ts: import ReactDOM from 'react-dom'; import * as React from 'react';

And for some reason this fix the import problems and allows NestJS to start but I still get errors when starting the front-end app (npm start from the front-end folder).

The issue is that for some reason npm/yarn install on the front-end folder will also install these node_modules into our NestJS folder. The packet manager gets confused because the react_modules for React are also present in the react_modules of NestJS.

TO FIX: Create a file called .env with this code: SKIP_PREFLIGHT_CHECK=true in the root folder of task-management-frontend

This is not a fix, just ignoring the issue and running the front-end app anyway.

Full errors from terminal if anyone wants more info:

Error after running npm run (inside front-end folder)

[email protected] start /home/electro/Documents/nestjs-task-management/task-management-frontend PORT=3001 react-app-rewired start

There might be a problem with the project dependency tree. It is likely not a bug in Create React App, but something you need to fix locally.

The react-scripts package provided by Create React App requires a dependency:

"babel-jest": "^24.8.0"

Don't try to install it manually: your package manager does it automatically. However, a different version of babel-jest was detected higher up in the tree:

/home/electro/Documents/nestjs-task-management/node_modules/babel-jest (version: 26.6.3)

Manually installing incompatible versions is known to cause hard-to-debug issues.

If you would prefer to ignore this check, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project. That will permanently disable this message but you might encounter other issues.

To fix the dependency tree, try following the steps below in the exact order:

  1. Delete package-lock.json (not package.json!) and/or yarn.lock in your project folder.
  2. Delete node_modules in your project folder.
  3. Remove "babel-jest" from dependencies and/or devDependencies in the package.json file in your project folder.
  4. Run npm install or yarn, depending on the package manager you use.

In most cases, this should be enough to fix the problem. If this has not helped, there are a few other things you can try:

  1. If you used npm, install yarn (http://yarnpkg.com/) and repeat the above steps with it instead. This may help because npm has known issues with package hoisting which may get resolved in future versions.

  2. Check if /home/electro/Documents/nestjs-task-management/node_modules/babel-jest is outside your project directory. For example, you might have accidentally installed something in your home folder.

  3. Try running npm ls babel-jest in your project folder. This will tell you which other package (apart from the expected react-scripts) installed babel-jest.

If nothing else helps, add SKIP_PREFLIGHT_CHECK=true to an .env file in your project. That would permanently disable this preflight check in case you want to proceed anyway.

P.S. We know this message is long but please read the steps above :-) We hope you find them helpful!

npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] start: PORT=3001 react-app-rewired start npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /home/electro/.npm/_logs/2021-02-04T22_30_47_800Z-debug.log

COMPLETE LOG

0 info it worked if it ends with ok 1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ] 2 info using [email protected] 3 info using [email protected] 4 verbose run-script [ 'prestart', 'start', 'poststart' ] 5 info lifecycle [email protected]~prestart: [email protected] 6 info lifecycle [email protected]~start: [email protected] 7 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true 8 verbose lifecycle [email protected]~start: PATH: /usr/share/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/electro/Documents/nestjs-task-management/task-management-frontend/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin 9 verbose lifecycle [email protected]~start: CWD: /home/electro/Documents/nestjs-task-management/task-management-frontend 10 silly lifecycle [email protected]~start: Args: [ '-c', 'PORT=3001 react-app-rewired start' ] 11 silly lifecycle [email protected]~start: Returned: code: 1 signal: null 12 info lifecycle [email protected]~start: Failed to exec start script 13 verbose stack Error: [email protected] start: PORT=3001 react-app-rewired start 13 verbose stack Exit status 1 13 verbose stack at EventEmitter. (/usr/share/npm/node_modules/npm-lifecycle/index.js:332:16) 13 verbose stack at EventEmitter.emit (events.js:315:20) 13 verbose stack at ChildProcess. (/usr/share/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14) 13 verbose stack at ChildProcess.emit (events.js:315:20) 13 verbose stack at maybeClose (internal/child_process.js:1021:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5) 14 verbose pkgid [email protected] 15 verbose cwd /home/electro/Documents/nestjs-task-management/task-management-frontend 16 verbose Linux 5.8.0-41-generic 17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start" 18 verbose node v12.18.2 19 verbose npm v6.14.8 20 error code ELIFECYCLE 21 error errno 1 22 error [email protected] start: PORT=3001 react-app-rewired start 22 error Exit status 1 23 error Failed at the [email protected] start script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ]

JoaoVictorDaijo avatar Feb 04 '21 22:02 JoaoVictorDaijo