前提・実現したいこと
ここに質問の内容を詳しく書いてください。
reactの開発環境をつくっているときに$npm startを入力すると下のコードのようにエラーをはきます。
これの解決方法をどうか教えていただきたいのです
発生している問題・エラーメッセージ
エラーメッセージ
該当のソースコード
javaScript (react) ソースコード > project@0.1.0 start /Users/hiro57/Documents/git/reactTodoList/project > 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: /Users/hiro57/node_modules/webpack (version: 4.29.5) 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 /Users/hiro57/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! npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! project@0.1.0 start: `react-scripts start` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the project@0.1.0 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! /Users/hiro57/.npm/_logs/2019-03-04T14_58_48_256Z-debug.log satouhiroshitonoMacBook-ea:project hiro57$ satouhiroshitonoMacBook-ea:project hiro57$ satouhiroshitonoMacBook-ea:project hiro57$ satouhiroshitonoMacBook-ea:project hiro57$ npm -v 6.7.0
試したこと
言われたとおり、ファイルを消してみたり、バージョンを変更したりなどいろいろしてみたのですがエラーをはきつづけてくれているわけです
ここに問題に対して試したことを記載してください。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
/Users/hiro57/.npm/_logs/2019-03-04T14_58_48_256Z-debug.logの内容はどうなってますか?
このような内容になっています
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm@6.7.0
3 info using node@v11.10.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle project@0.1.0~prestart: project@0.1.0
6 info lifecycle project@0.1.0~start: project@0.1.0
7 verbose lifecycle project@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle project@0.1.0~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/hiro57/Documents/git/reactTodoList/project/node_modules/.bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
9 verbose lifecycle project@0.1.0~start: CWD: /Users/hiro57/Documents/git/reactTodoList/project
10 silly lifecycle project@0.1.0~start: Args: [ '-c', 'react-scripts start' ]
11 silly lifecycle project@0.1.0~start: Returned: code: 1 signal: null
12 info lifecycle project@0.1.0~start: Failed to exec start script
13 verbose stack Error: project@0.1.0 start: `react-scripts start`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack at EventEmitter.emit (events.js:197:13)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:197:13)
13 verbose stack at maybeClose (internal/child_process.js:984:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
14 verbose pkgid project@0.1.0
15 verbose cwd /Users/hiro57/Documents/git/reactTodoList/project
16 verbose Darwin 17.7.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
18 verbose node v11.10.0
19 verbose npm v6.7.0
20 error code ELIFECYCLE
21 error errno 1
22 error project@0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the project@0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
npmのキャッシュをクリアしてから再実行してみてはどうでしょうか?
# インストールされたjsモジュールを全部消す
rm -rf node_modules
# インストールされたjsモジュールのバージョン情報を消す
rm package-lock.json yarn.lock
# npmのキャッシュをクリアする
npm cache clear --force
# 再度jsモジュールを全部入れ直して、実行する
npm install
改善しませんでした
エラーメッセージを読む限り、webpackのバージョンが合っていないようです。
エラーメッセージの手順にある通り、
1. package-lock.json or yarn.lockを削除
2. node_modulesディレクトリを丸ごと削除
3. package.jsonにwebpackがあれば削除
4. npm install or yarn install
を試してみるのが良いと思います。
create-react-appを使った場合、webpackは自動的にインストールされますので、何らかのカスタマイズをされていると思うのですが、インストール手順をご教示いただけないでしょうか?
npm をいちど消してもう一度バージョンを落としてから設定し直したらできました
アドバイスありがとうございました
解決できてよかったです^_^
回答2件
あなたの回答
tips
プレビュー