LoginSignup
4
3

More than 1 year has passed since last update.

create-react-appでエラーが出る

Last updated at Posted at 2021-08-14

環境

macbook pro 2015
macOs Bigsur

node v16.6.2
npm 7.20.3

エラー内容

npx create-react-app my-app

したところ、ターミナルに以下のエラー。

error jest-diff@27.0.6: The engine "node" is incompatible with this module. Expected vers│
ion "^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0". Got "14.4.0"                         │
error Found incompatible module.                                                         │
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.     │
`yarnpkg add @testing-library/jest-dom@^5.11.4 @testing-library/react@^11.1.0 @testing-li│
brary/user-event@^12.1.10 web-vitals@^1.0.1` failed

プロジェクトはできていたので、
npm run start
で起動したが、以下のエラーが出た。

Failed to compile
./src/reportWebVitals.js
Module not found: Can't resolve 'web-vitals' in '/Users/st/Documents/react_test/src'
This error occurred during the build time and cannot be dismissed.

解決方法

以下のように、--use-npmをつけるとうまくできた。

npx create-react-app my-app --use-npm

参考:
https://create-react-app.dev/docs/getting-started#selecting-a-package-manager

原因(予想)

create-react-appでの依存関係の解決がyarnで行われていた。

最近yarnを入れたからだと思うが、
npmで解決されてた依存関係をなぜかyarnで解決するように勝手に変更されてしまっていた。

ということだと思う。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3