Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation failed on Heroku: ERROR in ./node_modules & unmet peer dependency #2437

Closed
matthewgoodwin opened this issue Jan 18, 2020 · 6 comments

Comments

@matthewgoodwin
Copy link

matthewgoodwin commented Jan 18, 2020

Precompiling assets failed & unmet peer dependency
Hello Everyone,
I'm having issues pushing to Heroku. As requested @jakeNiemiec I'm opening a new issue and posting as much code as possible.
Status:
I recently implemented webpacker into an existing (older) program. I followed the instructions for installing webpacker 3.5, installed all the dependencies (I think), and updated. I ran yarn upgrade with no success #1078. I have added the "heroku/nodejs" build packs to my heroku configuration #2254, but that didnt work. I ran the rails assets:precompile, and that didnt work.. I have also ref several package.json updates suggested in #395 , and nothing seems to work.. I have no ideas what else to do..
In development, my code runs fine with no issues. My styles, JS, remotes and Mapbox function properly.
Issue:
When attempting to push to Heroku, my app fails to compile. I have several issues within the .node/modules/, but this seems to be a symptom of the issue, not the issue itself. Is there something wrong with my dependencies, webpacker version, webpacker.yml or babel?

CODE:
here is the failed Heroku build log:

-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.3.1
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Installing dependencies using bundler 1.17.3
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
       The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
       Fetching gem metadata from https://rails-assets.org/...
       Fetching gem metadata from https://rubygems.org/............
       Fetching gem metadata from https://rails-assets.org/...
       Fetching rake 13.0.1
       Installing rake 13.0.1
       Fetching concurrent-ruby 1.1.5
       Fetching minitest 5.13.0
       Using thread_safe 0.3.6
       Fetching builder 3.2.4
       Installing builder 3.2.4
       Installing minitest 5.13.0
       Installing concurrent-ruby 1.1.5
       Using erubis 2.7.0
       Fetching mini_portile2 2.4.0
       Fetching crass 1.0.5
       Installing mini_portile2 2.4.0
       Installing crass 1.0.5
       Fetching rack 2.0.8
       Installing rack 2.0.8
       Using nio4r 2.1.0
       Using websocket-extensions 0.1.3
       Using mini_mime 1.0.0
       Using arel 7.1.4
       Using execjs 2.7.0
       Using aws_cf_signer 0.1.3
       Using bcrypt 3.1.11
       Using rb-fsevent 0.10.2
       Using ffi 1.9.18
       Fetching method_source 0.9.2
       Installing method_source 0.9.2
       Fetching thor 0.20.3
       Installing thor 0.20.3
       Using bundler 1.17.3
       Using mime-types-data 3.2016.0521
       Using unf_ext 0.0.7.2
       Using netrc 0.11.0
       Using coffee-script-source 1.12.2
       Using orm_adapter 0.5.0
       Fetching geocoder 1.5.2
       Installing geocoder 1.5.2
       Using multi_json 1.12.2
       Using pg 0.21.0
       Using puma 3.11.0
       Using rails-assets-plugin 4.0.0
       Using tilt 2.0.8
       Using turbolinks-source 5.0.3
       Using will_paginate 3.1.8
       Fetching tzinfo 1.2.6
       Fetching i18n 0.9.5
       Using websocket-driver 0.6.5
       Using mail 2.7.0
       Using autoprefixer-rails 6.7.7.1
       Using uglifier 3.2.0
       Using rb-inotify 0.9.10
       Fetching nokogiri 1.10.7
       Installing i18n 0.9.5
       Installing tzinfo 1.2.6
       Using rack-test 0.6.3
       Using warden 1.2.7
       Fetching rack-proxy 0.6.5
       Installing rack-proxy 0.6.5
       Using sprockets 3.7.1
       Using mime-types 3.1
       Using unf 0.1.4
       Using coffee-script 2.4.1
       Using figaro 1.1.1
       Using turbolinks 5.0.1
       Using sass-listen 4.0.0
       Using domain_name 0.5.20161129
       Using sass 3.5.3
       Using http-cookie 1.0.3
       Using bootstrap-sass 3.3.7
       Using font-awesome-sass 4.7.0
       Using rest-client 2.0.0
       Using cloudinary 1.1.0
       Using activesupport 5.0.6
       Using globalid 0.4.1
       Using activemodel 5.0.6
       Using jbuilder 2.7.0
       Using pundit 1.1.0
       Using activerecord 5.0.6
       Using carrierwave 1.2.2
       Using activejob 5.0.6
       Installing nokogiri 1.10.7 with native extensions
       Fetching loofah 2.4.0
       Using rails-dom-testing 2.0.3
       Installing loofah 2.4.0
       Fetching rails-html-sanitizer 1.3.0
       Installing rails-html-sanitizer 1.3.0
       Using actionview 5.0.6
       Using actionpack 5.0.6
       Using actioncable 5.0.6
       Using actionmailer 5.0.6
       Using railties 5.0.6
       Using sprockets-rails 3.2.1
       Using simple_form 3.4.0
       Using momentjs-rails 2.20.1
       Using coffee-rails 4.2.2
       Using responders 2.3.0
       Using jquery-rails 4.3.1
       Using rails 5.0.6
       Using sass-rails 5.0.7
       Fetching webpacker 3.6.0
       Using bootstrap3-datetimepicker-rails 4.17.47
       Using devise 4.2.1
       Using simple_calendar 2.3.0
       Installing webpacker 3.6.0
       Bundle complete! 35 Gemfile dependencies, 87 gems now installed.
       Gems in the groups development and test were not installed.
       Bundled gems are installed into `./vendor/bundle`
       Removing loofah (2.1.1)
       Removing nokogiri (1.8.1)
       Removing rack (2.0.3)
       Removing i18n (0.9.1)
       Removing minitest (5.10.3)
       Removing concurrent-ruby (1.0.5)
       Removing tzinfo (1.2.4)
       Removing rails-html-sanitizer (1.0.3)
       Removing mini_portile2 (2.3.0)
       Removing method_source (0.9.0)
       Removing crass (1.0.3)
       Removing thor (0.20.0)
       Removing builder (3.2.3)
       Removing rake (12.3.0)
       Bundle completed (16.53s)
       Cleaning up the bundler cache.
       The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`.
-----> Installing node-v10.15.3-linux-x64
-----> Installing yarn-v1.16.0
-----> Detecting rake tasks
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       I, [2020-01-17T04:23:50.269810 #725]  INFO -- : Writing /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/public/assets/application-5c32d2eec6a5e23fd20cae7a7cfbc24bb96e487c2822bc5e672b3fe196c45d45.js
       I, [2020-01-17T04:23:50.270601 #725]  INFO -- : Writing /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/public/assets/application-5c32d2eec6a5e23fd20cae7a7cfbc24bb96e487c2822bc5e672b3fe196c45d45.js.gz
       I, [2020-01-17T04:24:03.024622 #725]  INFO -- : Writing /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/public/assets/application-0170fdd9b14dd6f6173a8256cdf6f21ab8f899a45d01f2c3729bedbe285b6731.css
       I, [2020-01-17T04:24:03.025477 #725]  INFO -- : Writing /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/public/assets/application-0170fdd9b14dd6f6173a8256cdf6f21ab8f899a45d01f2c3729bedbe285b6731.css.gz
       yarn install v1.16.0
       warning package.json: No license field
       warning No license field
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       info [email protected]: The platform "linux" is incompatible with this module.
       info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
       [3/4] Linking dependencies...
       warning "@rails/webpacker > [email protected]" has unmet peer dependency "caniuse-lite@^1.0.30000697".
       warning " > [email protected]" has unmet peer dependency "webpack@^2.2.0 || ^3.0.0".
       warning "webpack-dev-server > [email protected]" has unmet peer dependency "webpack@^1.0.0 || ^2.0.0 || ^3.0.0".
       [4/4] Building fresh packages...
       Done in 26.58s.
       Webpacker is installed 🎉 🍰
       Using /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/config/webpacker.yml file for setting up webpack paths
       Compiling…
       Compilation failed:
       
       Hash: f13122e2cff5f571d0e1
       Version: webpack 3.12.0
       Time: 21446ms
                                                              Asset       Size  Chunks                    Chunk Names
                                    map-805d697ba2878480ae36.js.map    1.01 kB       2  [emitted]         map
                                application-1c488e869b9464fb203d.js     916 kB       0  [emitted]  [big]  application
                                        map-805d697ba2878480ae36.js  541 bytes       2  [emitted]         map
       stylesheets/application-9a907b0fa2c91d7ba2c8b5aeb05cbd47.css   14 bytes       1  [emitted]         stylesheets/application
                            application-1c488e869b9464fb203d.js.map    1.12 MB       0  [emitted]         application
                stylesheets/application-c244a750edf6f7aa2078.js.map    1.03 kB       1  [emitted]         stylesheets/application
                    stylesheets/application-c244a750edf6f7aa2078.js  549 bytes       1  [emitted]         stylesheets/application
                                                      manifest.json  542 bytes          [emitted]         
                 stylesheets/application-c244a750edf6f7aa2078.js.gz  341 bytes          [emitted]         
                                     map-805d697ba2878480ae36.js.gz  337 bytes          [emitted]         
                                                   manifest.json.gz  200 bytes          [emitted]         
                             application-1c488e869b9464fb203d.js.gz     240 kB          [emitted]         
          [1] ./app/javascript/packs/application.js 998 bytes {0} [built]
          [4] (webpack)/buildin/global.js 509 bytes {0} [built]
          [6] ./app/javascript/plugins/init_mapbox.js 1.02 kB {0} [built]
          [8] ./app/javascript/packs/map.js 0 bytes {2} [built]
          [9] ./app/javascript/packs/stylesheets/application.scss 41 bytes {1} [built]
         [13] ./node_modules/css-loader??ref--2-2!./node_modules/postcss-loader/lib??ref--2-3!./node_modules/sass-loader/lib/loader.js??ref--2-4!./app/javascript/packs/stylesheets/application.scss 418 bytes [built]
           + 9 hidden modules
       
       ERROR in ./node_modules/mapbox-gl/dist/mapbox-gl.css
       Module build failed: ModuleBuildError: Module build failed: TypeError: Cannot read property 'toFixed' of undefined
           at strongRound (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/plugins/convertPathData.js:766:21)
           at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/plugins/convertPathData.js:424:17
           at Array.filter (<anonymous>)
           at filters (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/plugins/convertPathData.js:272:17)
           at Object.exports.fn (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/plugins/convertPathData.js:79:20)
           at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/plugins.js:59:45
           at Array.filter (<anonymous>)
           at monkeys (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/plugins.js:46:39)
           at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/plugins.js:66:17
           at Array.filter (<anonymous>)
           at monkeys (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/plugins.js:46:39)
           at perItem (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/plugins.js:77:12)
           at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/plugins.js:18:24
           at Array.forEach (<anonymous>)
           at module.exports (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/plugins.js:14:13)
           at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo.js:63:17
           at SAXParser.sax.onend (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/svg2js.js:156:13)
           at emit (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/sax/lib/sax.js:624:35)
           at end (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/sax/lib/sax.js:667:5)
           at SAXParser.write (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/sax/lib/sax.js:975:14)
           at SAXParser.close (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/sax/lib/sax.js:157:38)
           at module.exports (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/svg2js.js:169:28)
           at module.exports.SVGO._optimizeOnce (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo.js:56:5)
           at module.exports.SVGO.optimize (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo.js:49:11)
           at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/postcss-svgo/dist/index.js:64:25
           at new Promise (<anonymous>)
           at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/postcss-svgo/dist/index.js:63:23
           at walk (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/postcss-value-parser/lib/walk.js:7:16)
           at ValueParser.walk (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/postcss-value-parser/lib/index.js:18:3)
           at minifyPromise (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/postcss-svgo/dist/index.js:33:64)
           at runLoaders (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/webpack/lib/NormalModule.js:195:19)
           at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/loader-runner/lib/LoaderRunner.js:367:11
           at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/loader-runner/lib/LoaderRunner.js:233:18
           at context.callback (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/loader-runner/lib/LoaderRunner.js:111:13)
           at Object.<anonymous> (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/css-loader/lib/loader.js:50:18)
           at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/css-loader/lib/processCss.js:236:4
        @ ./node_modules/mapbox-gl/dist/mapbox-gl.css
        @ ./app/javascript/packs/application.js
       
       ERROR in ./node_modules/css-loader??ref--1-2!./node_modules/postcss-loader/lib??ref--1-3!./node_modules/mapbox-gl/dist/mapbox-gl.css
       Module build failed: TypeError: Cannot read property 'toFixed' of undefined
           at strongRound (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/plugins/convertPathData.js:766:21)
           at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/plugins/convertPathData.js:424:17
           at Array.filter (<anonymous>)
           at filters (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/plugins/convertPathData.js:272:17)
           at Object.exports.fn (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/plugins/convertPathData.js:79:20)
           at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/plugins.js:59:45
           at Array.filter (<anonymous>)
           at monkeys (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/plugins.js:46:39)
           at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/plugins.js:66:17
           at Array.filter (<anonymous>)
           at monkeys (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/plugins.js:46:39)
           at perItem (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/plugins.js:77:12)
           at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/plugins.js:18:24
           at Array.forEach (<anonymous>)
           at module.exports (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/plugins.js:14:13)
           at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo.js:63:17
           at SAXParser.sax.onend (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/svg2js.js:156:13)
           at emit (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/sax/lib/sax.js:624:35)
           at end (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/sax/lib/sax.js:667:5)
           at SAXParser.write (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/sax/lib/sax.js:975:14)
           at SAXParser.close (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/sax/lib/sax.js:157:38)
           at module.exports (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/svg2js.js:169:28)
           at module.exports.SVGO._optimizeOnce (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo.js:56:5)
           at module.exports.SVGO.optimize (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo.js:49:11)
           at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/postcss-svgo/dist/index.js:64:25
           at new Promise (<anonymous>)
           at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/postcss-svgo/dist/index.js:63:23
           at walk (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/postcss-value-parser/lib/walk.js:7:16)
           at ValueParser.walk (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/postcss-value-parser/lib/index.js:18:3)
           at minifyPromise (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/postcss-svgo/dist/index.js:33:64)
        @ ./node_modules/mapbox-gl/dist/mapbox-gl.css 2:14-122
        @ ./app/javascript/packs/application.js
       Child extract-text-webpack-plugin node_modules/extract-text-webpack-plugin/dist node_modules/css-loader/index.js??ref--1-2!node_modules/postcss-loader/lib/index.js??ref--1-3!node_modules/mapbox-gl/dist/mapbox-gl.css:
              1 module
           
           ERROR in ./node_modules/css-loader??ref--1-2!./node_modules/postcss-loader/lib??ref--1-3!./node_modules/mapbox-gl/dist/mapbox-gl.css
           Module build failed: TypeError: Cannot read property 'toFixed' of undefined
               at strongRound (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/plugins/convertPathData.js:766:21)
               at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/plugins/convertPathData.js:424:17
               at Array.filter (<anonymous>)
               at filters (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/plugins/convertPathData.js:272:17)
               at Object.exports.fn (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/plugins/convertPathData.js:79:20)
               at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/plugins.js:59:45
               at Array.filter (<anonymous>)
               at monkeys (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/plugins.js:46:39)
               at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/plugins.js:66:17
               at Array.filter (<anonymous>)
               at monkeys (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/plugins.js:46:39)
               at perItem (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/plugins.js:77:12)
               at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/plugins.js:18:24
               at Array.forEach (<anonymous>)
               at module.exports (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/plugins.js:14:13)
               at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo.js:63:17
               at SAXParser.sax.onend (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/svg2js.js:156:13)
               at emit (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/sax/lib/sax.js:624:35)
               at end (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/sax/lib/sax.js:667:5)
               at SAXParser.write (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/sax/lib/sax.js:975:14)
               at SAXParser.close (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/sax/lib/sax.js:157:38)
               at module.exports (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo/svg2js.js:169:28)
               at module.exports.SVGO._optimizeOnce (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo.js:56:5)
               at module.exports.SVGO.optimize (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/svgo/lib/svgo.js:49:11)
               at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/postcss-svgo/dist/index.js:64:25
               at new Promise (<anonymous>)
               at /tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/postcss-svgo/dist/index.js:63:23
               at walk (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/postcss-value-parser/lib/walk.js:7:16)
               at ValueParser.walk (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/postcss-value-parser/lib/index.js:18:3)
               at minifyPromise (/tmp/build_fe2e1dd8e988e4d3df25e161a6476e43/node_modules/postcss-svgo/dist/index.js:33:64)
       Child extract-text-webpack-plugin node_modules/extract-text-webpack-plugin/dist node_modules/css-loader/index.js??ref--2-2!node_modules/postcss-loader/lib/index.js??ref--2-3!node_modules/sass-loader/lib/loader.js??ref--2-4!app/javascript/packs/stylesheets/application.scss:
              [0] ./node_modules/css-loader??ref--2-2!./node_modules/postcss-loader/lib??ref--2-3!./node_modules/sass-loader/lib/loader.js??ref--2-4!./app/javascript/packs/stylesheets/application.scss 418 bytes {0} [built]
               + 1 hidden module
       
 !
 !     Precompiling assets failed.
 !
 !     Push rejected, failed to compile Ruby app.
 !     Push failed

package.json

{
  "dependencies": {
    "@rails/webpacker": "3.5",
    "bootstrap": "^4.4.1",
    "jquery": "^3.4.1",
    "mapbox-gl": "^1.6.1",
    "popper.js": "^1.16.0"
  },
  "devDependencies": {
    "webpack-dev-server": "2.11.2"
  }
}

babel.config.js

module.exports = function(api) {
  var validEnv = ['development', 'test', 'production']
  var currentEnv = api.env()
  var isDevelopmentEnv = api.env('development')
  var isProductionEnv = api.env('production')
  var isTestEnv = api.env('test')

  if (!validEnv.includes(currentEnv)) {
    throw new Error(
      'Please specify a valid `NODE_ENV` or ' +
        '`BABEL_ENV` environment variables. Valid values are "development", ' +
        '"test", and "production". Instead, received: ' +
        JSON.stringify(currentEnv) +
        '.'
    )
  }

  return {
    presets: [
      isTestEnv && [
        '@babel/preset-env',
        {
          targets: {
            node: 'current'
          }
        }
      ],
      (isProductionEnv || isDevelopmentEnv) && [
        '@babel/preset-env',
        {
          forceAllTransforms: true,
          useBuiltIns: 'entry',
          corejs: 3,
          modules: false,
          exclude: ['transform-typeof-symbol']
        }
      ]
    ].filter(Boolean),
    plugins: [
      'babel-plugin-macros',
      '@babel/plugin-syntax-dynamic-import',
      isTestEnv && 'babel-plugin-dynamic-import-node',
      '@babel/plugin-transform-destructuring',
      [
        '@babel/plugin-proposal-class-properties',
        {
          loose: true
        }
      ],
      [
        '@babel/plugin-proposal-object-rest-spread',
        {
          useBuiltIns: true
        }
      ],
      [
        '@babel/plugin-transform-runtime',
        {
          helpers: false,
          regenerator: true,
          corejs: false
        }
      ],
      [
        '@babel/plugin-transform-regenerator',
        {
          async: false
        }
      ]
    ].filter(Boolean)
  }
}

config/webpack/environment.js

const { environment } = require('@rails/webpacker')
// Bootstrap 4 has a dependency over jQuery & Popper.js:
const webpack = require('webpack')
environment.plugins.prepend('Provide',
  new webpack.ProvidePlugin({
    $: 'jquery',
    jQuery: 'jquery',
    Popper: ['popper.js', 'default']
  })
)
module.exports = environment

webpacker.yml

# Note: You must restart bin/webpack-dev-server for changes to take effect

default: &default
  source_path: app/javascript
  source_entry_path: packs
  public_output_path: packs
  cache_path: tmp/cache/webpacker
  webpack_compile_output: false

  # Additional paths webpack should lookup modules
  # ['app/assets', 'engine/foo/app/assets']
  resolved_paths: ['app/assets']

  # Reload manifest.json on all requests so we reload latest compiled packs
  cache_manifest: false

  extensions:
    - .js
    - .sass
    - .scss
    - .css
    - .module.sass
    - .module.scss
    - .module.css
    - .png
    - .svg
    - .gif
    - .jpeg
    - .jpg

development:
  <<: *default
  compile: true

  # Reference: https://webpack.js.org/configuration/dev-server/
  dev_server:
    https: false
    host: localhost
    port: 3035
    public: localhost:3035
    hmr: false
    # Inline should be set to true if using HMR
    inline: true
    overlay: true
    compress: true
    disable_host_check: true
    use_local_ip: false
    quiet: false
    headers:
      'Access-Control-Allow-Origin': '*'
    watch_options:
      ignored: '**/node_modules/**'


test:
  <<: *default
  compile: true

  # Compile test packs to a separate directory
  public_output_path: packs-test

production:
  <<: *default

  # Production depends on precompilation of packs prior to booting for performance.
  compile: false

  # Cache manifest.json for performance
  cache_manifest: true

./app/javascript/packs/application.js

import 'bootstrap';
// import 'bootstrap/dist/css/bootstrap.min.css';
import 'mapbox-gl/dist/mapbox-gl.css'; 
import { initMapbox } from '../plugins/init_mapbox';
initMapbox();

app/javascript/plugins/init_mapbox.js

//app/javascript/plugins/init_mapbox.js
import mapboxgl from 'mapbox-gl';

const mapElement = document.getElementById('map');

const buildMap = () => {
  mapboxgl.accessToken = mapElement.dataset.mapboxApiKey;
  return new mapboxgl.Map({
    container: 'map',
    style: 'mapbox://styles/mapbox/streets-v10'
  });
};

const addMarkersToMap = (map, markers) => {
  markers.forEach((marker) => {
    new mapboxgl.Marker()
      .setLngLat([ marker.lng, marker.lat ])
      .addTo(map);
  });
};

const fitMapToMarkers = (map, markers) => {
  const bounds = new mapboxgl.LngLatBounds();
  markers.forEach(marker => bounds.extend([ marker.lng, marker.lat ]));
  map.fitBounds(bounds, { padding: 70, maxZoom: 15 });
};

const initMapbox = () => {
  if (mapElement) {
    const map = buildMap();
    const markers = JSON.parse(mapElement.dataset.markers);
    addMarkersToMap(map, markers);
    fitMapToMarkers(map, markers);
  }
};

export { initMapbox };

app/view/layouts/application.html.erb

<!DOCTYPE html>
<html>
  <head>
    
 [...]

    <!-- calls to app/assets/stylesheets/application.scss -->
    <%= stylesheet_link_tag 'application'%>
    <%= stylesheet_pack_tag 'application'%>
    <script defer src="https://use.fontawesome.com/releases/v5.0.10/js/all.js" integrity="sha384-slN8GvtUJGnv6ca26v8EzVaR9DC58QEwsIk9q1QXdCU8Yu8ck/tL/5szYlBbqmS+" crossorigin="anonymous"></script>

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css">
    <!-- <style>*{border: 1px solid red !important;}</style> -->
  </head>
  <body>
    <%= render 'shared/navbar' %>
    <%= render 'shared/flashes' %>
    <div>
      <%= yield %>
      <%= javascript_include_tag 'application' %> <!-- from app/assets/javascripts/application.js -->
      <%= javascript_pack_tag 'application' %> <!-- from app/javascript/packs/application.js -->
    </div>
    <%= render 'shared/footer' %>
  </body>
</html>

Cheers everyone!

@matthewgoodwin matthewgoodwin changed the title Compilation failed: ERROR in ./node_modules Compilation failed: ERROR in ./node_modules & unmet peer dependency Jan 29, 2020
@matthewgoodwin matthewgoodwin changed the title Compilation failed: ERROR in ./node_modules & unmet peer dependency Compilation failed on Heroku: ERROR in ./node_modules & unmet peer dependency Jan 30, 2020
@jakeNiemiec
Copy link
Member

@matthewgoodwin Thank you for posting the extra info, sorry it took so long to get back to you.

In development, my code runs fine with no issues...When attempting to push to Heroku, my app fails to compile. I have several issues within the .node/modules/, but this seems to be a symptom of the issue, not the issue itself. Is there something wrong with my dependencies, webpacker version, webpacker.yml or babel?

It sounds like the classic case of babel mangling the pre-compiled node_modules code that mapbox-gl provides. Webpacker added a way to control this in webpacker@4:

//config/webpack/environment.js
const { environment } = require('@rails/webpacker');
// Bootstrap 4 has a dependency over jQuery & Popper.js:
const webpack = require('webpack');
environment.plugins.prepend('Provide',
  new webpack.ProvidePlugin({
    $: 'jquery',
    jQuery: 'jquery',
    Popper: ['popper.js', 'default']
  })
);
+environment.loaders.delete('nodeModules');
module.exports = environment;

I think that webpacker@4 + environment.loaders.delete('nodeModules') will fix your problem.

There is also a known issue with mapbox-gl: #2131 (comment)

@matthewgoodwin
Copy link
Author

Hey thanks for the reply, this didnt resolve the issue.. Now, I get the same errors when I run rails assets:precompile and I still cant push to heroku. Currently, the node_modules directory is listed in my .gitignore file, and ignored on my repo. I know it's a long shot, but could this be part of the issue? I think I'm going to install webpacker 4; hopefully this resolves the issue..

@jakeNiemiec
Copy link
Member

the node_modules directory is listed in my .gitignore file, and ignored on my repo. I know it's a long shot, but could this be part of the issue?

No, we know that node_modules is working because we are able to get webpack errors.

I think I'm going to install webpacker 4; hopefully this resolves the issue..

I am pretty confident that webpacker 4 will help resolve this issue. Just be sure to lightly read the upgrade guide, these are the parts that relate to your problem:

@matthewgoodwin
Copy link
Author

matthewgoodwin commented Mar 16, 2020

Thanks again @jakeNiemiec , I cleared my app of any and all things webpacker and mapbox, ran a fresh install of webpacker 4.x, and reinstalled mapbox. Now I get a whole new set of errors, but my research seem to circle back to the same posts.
Here are the console errors:

Uncaught Error: An API access token is required to use Mapbox GL. See https://www.mapbox.com/api-documentation/#access-tokens-and-token-scopes
    at N../node_modules/mapbox-gl/dist/mapbox-gl.js.N._makeAPIURL (mapbox-gl.js:29)
    at N../node_modules/mapbox-gl/dist/mapbox-gl.js.N.normalizeStyleURL (mapbox-gl.js:29)
    at i.loadURL (mapbox-gl.js:33)
    at r._updateStyle (mapbox-gl.js:33)
    at r.setStyle (mapbox-gl.js:33)
    at new r (mapbox-gl.js:33)
    at initMapbox (init_mapbox.js:10)
    at Module../app/javascript/packs/application.js (application.js:6)
    at __webpack_require__ (bootstrap:19)
    at bootstrap:83

My API Key/Token is set in my .env file, and referenced in the html..

Uncaught ReferenceError: _typeof is not defined
    at kr (2a863ba2-21b1-43b5-bfcb-ff59a3523be2:5138)
    at 2a863ba2-21b1-43b5-bfcb-ff59a3523be2:6970
    at new ei (2a863ba2-21b1-43b5-bfcb-ff59a3523be2:6987)
    at new yi (2a863ba2-21b1-43b5-bfcb-ff59a3523be2:7272)
    at 2a863ba2-21b1-43b5-bfcb-ff59a3523be2:9265
    at 2a863ba2-21b1-43b5-bfcb-ff59a3523be2:15053
2a863ba2-21b1-43b5-bfcb-ff59a3523be2:5138 Uncaught ReferenceError: _typeof is not defined
    at kr (2a863ba2-21b1-43b5-bfcb-ff59a3523be2:5138)
    at 2a863ba2-21b1-43b5-bfcb-ff59a3523be2:6970
    at new ei (2a863ba2-21b1-43b5-bfcb-ff59a3523be2:6987)
    at new yi (2a863ba2-21b1-43b5-bfcb-ff59a3523be2:7272)
    at 2a863ba2-21b1-43b5-bfcb-ff59a3523be2:9265
    at 2a863ba2-21b1-43b5-bfcb-ff59a3523be2:15053
kr @ 2a863ba2-21b1-43b5-bfcb-ff59a3523be2:5138
(anonymous) @ 2a863ba2-21b1-43b5-bfcb-ff59a3523be2:6970
ei @ 2a863ba2-21b1-43b5-bfcb-ff59a3523be2:6987
yi @ 2a863ba2-21b1-43b5-bfcb-ff59a3523be2:7272
(anonymous) @ 2a863ba2-21b1-43b5-bfcb-ff59a3523be2:9265
(anonymous) @ 2a863ba2-21b1-43b5-bfcb-ff59a3523be2:15053

not sure what the above errors means, but my research has led me back to this post.
I hope this works!

If I choose to use:
//config/webpack/environment.js
+environment.loaders.delete('nodeModules');
Would this permanently delete the nodeModules; or is it deleted so long as the line of code exists?? webpacker rebuilds its packages when called, correct?

If I chose to exclude node_modules from being transpiled by babel-loader:
nodeModulesLoader.exclude.push(/some-library/) // replace `some-library` with // the actual path to exclude
Can you explain this^ line[...].push(/some-library/); what is the actual path to be excluded in this case??

Of the two choices, the second option: excluding node_modules From... seems like the least aggressive choice. Am I correct in my assumption?!

@jakeNiemiec
Copy link
Member

Would this permanently delete the nodeModules

In this case nodeModules is just the name of the loader that is mangling mapbox. You are deleting the instruction that compiles node_modules. You are not permanently removing anything.

Can you explain this^ line ... what is the actual path to be excluded in this case?

It is regex, this is an extensive topic that you can read about here https://webpack.js.org/configuration/module/#rule-conditions

... seems like the least aggressive choice. Am I correct in my assumption?!

No, the problem is that the nodeModules loader is an aggressive choice to begin with. You generally never want to compile node_modules.

@matthewgoodwin
Copy link
Author

All set here! @jakeNiemiec , your suggestions worked, thanks for the support!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants