LoginSignup
0
1

More than 5 years have passed since last update.

Webpackを使ったプロジェクトをHerokuにdeployしたときuglifyjs-webpack-plugin周りで問題が起きる時の対処法

Last updated at Posted at 2017-09-06

Webpackを使ってJSをビルドするプロジェクトをHerokuにdeployするとき uglifyjs-webpack-plugin 周りで問題が発生しました。

TL;DR

  • 問題は uglifyjs-webpack-plugin ではなかった
  • 真の問題はherokuのyarnのバージョンがpackage.jsonで固定していないと 1.0.0 を使ってしまうこと。
  • package.jsonengines.yarn0.27.5 で固定すればOK。
"engines": {
  "node": "6.10.0",
  "npm": "3.10.10",
  "yarn": "0.27.5"
}

経緯

-----> Installing binaries
       engines.node (package.json):  6.10.0
       engines.npm (package.json):   3.10.10
       engines.yarn (package.json):  unspecified (use default)

       Resolving node version 6.10.0...
       Downloading and installing node 6.10.0...
       npm 3.10.10 already installed with node
       Resolving yarn version (latest)...
       Downloading and installing yarn (1.0.0)...
       Installed yarn 1.0.0
-----> Restoring cache
       Skipping cache restore (new-signature)
-----> Building dependencies
       Installing node modules (yarn.lock)
       yarn install v1.0.0
       warning package.json: No license field
       warning hogehoge@1.0.0: No license field
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       info fsevents@1.1.1: The platform "linux" is incompatible with this module.
       info "fsevents@1.1.1" is an optional dependency and failed compatibility check. Excluding it from installation.
       [3/4] Linking dependencies...
       warning "babel-loader@7.1.1" has incorrect peer dependency "babel-core@6 || 7 || ^7.0.0-alpha || ^7.0.0-beta || ^7.0.0-rc".
       warning "ajv-keywords@2.1.0" has incorrect peer dependency "ajv@>=5.0.0".
       warning "ajv-keywords@1.5.1" has incorrect peer dependency "ajv@>=4.10.0".
       [4/4] Building fresh packages...
       error An unexpected error occurred: "/tmp/build_b905384b61a4487cb48dfbfdfaee975f/hogehoge-a6903aed1b40f65e648aed06e1a683dd6da3717b/node_modules/uglifyjs-webpack-plugin: EROFS: read-only file system, access '/usr/local/bin'".
       info If you think this is a bug, please open a bug report with the information provided in "/tmp/build_b905384b61a4487cb48dfbfdfaee975f/hogehoge-a6903aed1b40f65e648aed06e1a683dd6da3717b/yarn-error.log".
       info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
-----> Build failed

       We're sorry this build is failing! You can troubleshoot common issues here:
       https://devcenter.heroku.com/articles/troubleshooting-node-deploys

       Some possible problems:

       - This project was built with yarn, which is new and under development. Some projects can still be built more reliably with npm
       https://devcenter.heroku.com/articles/nodejs-support#build-behavior

       Love,
       Heroku

 !     Push rejected, failed to compile Node.js app.
 !     Push failed
Build finished
heroku.com Blogs Careers Documentation
Support
Terms of Service Privacy Cookies © 2017 Salesforce.com

なんだかread-onlyの場所を触ってしまった事による不具合のように見えます(JS力が足りない)

昨日(2017/09/05)はデプロイしても特に問題なかったのでいろいろ唸っていた所、ログからyarn のバージョンが 1.0.0 になっているのを発見しました。

-----> Installing binaries
       engines.node (package.json):  6.10.0
       engines.npm (package.json):   3.10.10
       engines.yarn (package.json):  unspecified (use default)

       Resolving node version 6.10.0...
       Downloading and installing node 6.10.0...
       npm 3.10.10 already installed with node
       Resolving yarn version (latest)...
       Downloading and installing yarn (1.0.0)...
       Installed yarn 1.0.0

どうやらちょうど昨日にyarnのバージョンが 1.0.0 に上がったようでした。

バージョンを固定する方法はherokuのドキュメントに書いてありました。

個々の記述に従ってバージョンを固定した所、問題なくデプロイができることを確認しました。

デプロイに関わるものはちゃんとバージョンを固定しないとハマりますね。反省です。

なんでこんなエラーが出るかがよくわかっていないのが、個人的には問題かなと感じております。

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