0
0

More than 1 year has passed since last update.

pnpmが`SKIP_PREFLIGHT_CHECK=true`を求めてくる場合の対処法

Posted at

⚠️この情報は本記事の投稿時点で有効であったものです。各自エラーメッセージやissueを確認してください。⚠️

エラーメッセージの例

❯ pnpm build

> (プロジェクト名)@0.1.0 build /home/matoruru/Code/(省略)
> craco build


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:

  "webpack": "4.44.2"

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

  /home/matoruru/Code/(省略)/node_modules/.pnpm/node_modules/webpack (version: 4.46.0) 

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 "webpack" 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:

  5. 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.

  6. Check if /home/matoruru/Code/(省略)/node_modules/.pnpm/node_modules/webpack is outside your project directory.
     For example, you might have accidentally installed something in your home folder.

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

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!

 ELIFECYCLE  Command failed with exit code 1.

エラーメッセージが指示してくれている手順を踏んでも解決には至らず・・・。

解決策

package.json内に以下の記述を追加します。

  "pnpm": {
    "overrides": {
      "webpack": "4.44.2"
    }
  },

参考にしたissue

私のpnpmプロジェクトでも@react/storybookを使っていたので、同じくこの部分が問題になっていたようです。

筆者について

フォローしていただけると励みになります!

Twitter: https://twitter.com/_matoruru
GitHub: https://github.com/matoruru

0
0
1

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
0
0