前提・実現したいこと
reactのチュートリアルをしようと思いました。
react自体は正直まだよく分からないです。
npx create-react-app my-app
をしたあとに、
cd my-app
でmy-app
に移動し、yarn start
をしたらエラーが出ました。
発生している問題・エラーメッセージ
チュートリアルの通りにnpx create-react-app my-app
をしました。
PS D:\skytomo\Documents\Programming\React> npx create-react-app my-app npx: installed 63 in 18.908s Creating a new React app in D:\skytomo\Documents\Programming\React\my-app. warning You don't appear to have an internet connection. Try the --offline flag to use the cache for registry queries. (node:20600) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. Installing packages. This might take a couple of minutes. Installing react, react-dom, and react-scripts... You appear to be offline. Falling back to the local Yarn cache. yarn add v1.6.0 (node:36648) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. [1/4] Resolving packages... [2/4] Fetching packages... info fsevents@1.2.7: The platform "win32" is incompatible with this module. info "fsevents@1.2.7" is an optional dependency and failed compatibility check. Excluding it from installation. info fsevents@1.2.4: The platform "win32" is incompatible with this module. info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation. [3/4] Linking dependencies... warning "react-scripts > pnp-webpack-plugin > ts-pnp@1.0.1" has unmet peer dependency "typescript@*". [4/4] Building fresh packages... success Saved lockfile. success Saved 6 new dependencies. info Direct dependencies ├─ react-dom@16.8.5 ├─ react-scripts@2.1.8 └─ react@16.8.5 info All dependencies ├─ fork-ts-checker-webpack-plugin@1.0.0-alpha.6 ├─ react-dev-utils@8.0.0 ├─ react-dom@16.8.5 ├─ react-scripts@2.1.8 ├─ react@16.8.5 └─ scheduler@0.13.5 Done in 332.07s. Initialized a git repository. Success! Created my-app at D:\skytomo\Documents\Programming\React\my-app Inside that directory, you can run several commands: yarn start Starts the development server. yarn build Bundles the app into static files for production. yarn test Starts the test runner. yarn eject Removes this tool and copies build dependencies, configuration files and scripts into the app directory. If you do this, you can’t go back! We suggest that you begin by typing: cd my-app yarn start Happy hacking!
npx create-react-app my-app
をしたあとに、
cd my-app
でmy-app
に移動し、yarn start
をしたらエラーが出ました。
PS D:\skytomo\Documents\Programming\React\my-app> yarn start yarn run v1.6.0 (node:26504) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. $ react-scripts 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: "webpack": "4.28.3" 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: D:\skytomo\node_modules\webpack (version: 4.25.1) 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 D:\skytomo\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! error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
試したこと
エラーに書かれている通りに、実行してみました。
yarn.lock
を削除しました。(package-lock.json
はmy-app
の中にありませんでした。)node_modules
を削除しました。- (
webpack
はmy-app
の中にありませんでした。) yarn
を実行しました。そして成功しました。
PS D:\skytomo\Documents\Programming\React\my-app> yarn yarn install v1.6.0 (node:28020) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. [1/4] Resolving packages... success Already up-to-date. Done in 1.05s.
ここで、もう一度yarn start
をしましたが、同じエラーが出ました。
5は最初からyarnを使っているので関係ありません。
6は「webpackがプロジェクトディレクトリの外にあるかどうかを確認します。」という意味がよく分からなかったので、飛ばしました。ここのファイルにしか今回ダウンロードしていないので、多分関係ないと思いました。
7を実行したら、下のように出てきました。
PS D:\skytomo\Documents\Programming\React\my-app> npm ls webpack my-app@0.1.0 D:\skytomo\Documents\Programming\React\my-app `-- react-scripts@2.1.8 `-- webpack@4.28.3
それで結局、解決方法が分かりません。
ここからどうすればいいのでしょうか。
ちなみに.envというファイルにSKIP_PREFLIGHT_CHECK=true
を書いたら、動くようになりました。
PS D:\skytomo\Documents\Programming\React\my-app> yarn start yarn run v1.6.0 (node:280) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. $ react-scripts start Starting the development server... Compiled successfully! You can now view my-app in the browser. Local: http://localhost:3000/ On Your Network: http://172.20.10.2:3000/ Note that the development build is not optimized. To create a production build, use yarn build.
が、あまりにも気持ち悪いので、(普通はそうならないはずだから)
原因と解決方法を教えていただきたいです。
補足情報
OS: Windows 10
npm 6.9.0
npx 6.9.0
node v10.15.3
yarn 1.6.0
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。