状況
Unicornを起動した際に画像のようなエラーが出てしまいました。
原因をログで調べたところアセットパイプラインがインストールできておらず「error Command "webpack" not found」と出てしまいました。yarnやwebpackを再インストールしたり、packege.jsonに「"@rails/webpacker": "5.2.1"」と追加したりとしましたが相変わらずの状態です。
何が原因かご教授いただければと思います。
コード
ターミナル [ec2-user@ip-172-31-33-129 note]$ rails assets:precompile RAILS_ENV=production yarn install v1.22.5 warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json. [1/4] Resolving packages... [2/4] Fetching packages... info fsevents@2.3.2: The platform "linux" is incompatible with this module. info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation. info fsevents@1.2.13: The platform "linux" is incompatible with this module. info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation. error webpack-dev-server@4.2.1: The engine "node" is incompatible with this module. Expected version ">= 12.13.0". Got "10.24.1" error Found incompatible module. info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command. Compiling... Compilation failed: yarn run v1.22.5 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. error Command "webpack" not found.
{ "name": "note", "private": true, "dependencies": { "@babel/preset-react": "^7.14.5", "@babel/preset-typescript": "^7.15.0", "@nathanvda/cocoon": "^1.2.14", "@rails/actioncable": "^6.0.0", "@rails/activestorage": "^6.0.0", "@rails/ujs": "^6.0.0", "@rails/webpacker": "5.2.1", "@types/react": "^17.0.18", "@types/react-dom": "^17.0.9", "babel-plugin-transform-react-remove-prop-types": "^0.4.24", "bootstrap": "^5.1.0", "cocoon": "github:nathanvda/cocoon#c24ba53", "cocoon-js": "^0.0.5", "jquery": "^3.6.0", "note": "^1.2.1", "popper.js": "^1.16.1", "prop-types": "^15.7.2", "react": "^17.0.2", "react-dom": "^17.0.2", "react_ujs": "^2.6.1", "turbolinks": "^5.2.0", "typescript": "^4.3.5" }, "version": "0.1.0", "devDependencies": { "@webpack-cli/serve": "^1.5.2", "webpack": "^4.46.0", "webpack-cli": "^3.3.12", "webpack-dev-server": "^4.2.1" }, "description": "", "main": "babel.config.js", "directories": { "lib": "lib", "test": "test" }, "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", "url": "git+https://github.com/aseat/note.git" }, "keywords": [], "author": "", "license": "ISC", "bugs": { "url": "https://github.com/aseat/note/issues" }, "homepage": "https://github.com/aseat/note#readme" }
試したこと
・package.jsonに「"@rails/webpacker": "5.2.1" 」と追記
・下記サイトを参考に実施
https://github.com/rails/webpacker/issues/522
https://qiita.com/ryokkkke/items/5cfbf91fc3e3a3831da6
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。