-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Asset compilation error during heroku deployment, webpacker 3, react 16 #915
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
Comments
Do you have a |
Could you please paste the content please? |
Yes, I have the babelrc file in the app root.
|
Is |
Yes I see babel-preset-react in the devDependencies.
|
Post 3.0+ you don't need these dependencies so just remove everything that's webpacker 2.0 specific and then remove |
After I upgraded to webpack 3, I ran |
All deps now lives with npm package, https://github.com/rails/webpacker/blob/master/package.json so just remove everything except |
Here is more background on why it's failing: https://devcenter.heroku.com/articles/nodejs-support#devdependencies |
Success! 🥇 Thanks for the help. Here are a list of things I did going from Webpacker 2 to Webpacker 3.
A couple of other things to consider.
Closing this issue now. Thanks again. |
In my case everything was working in the dev env but failed in production with the same error:
Turned out to be a missing In the meantime I upgraded versions of the gem and package and everything worked correctly. So I'm not sure if this was fixed or a mistake on my side (plausible). Thanks for the help and this project 👏 |
@gauravtiwari What about I know Rails 5.1+ has the middleware to re-build packs on-the-fly, but I'm more comfortable using a separate process with I can't see the Or am I missing something else? |
@gauravtiwari I'm receiving this error as well after upgrading to Rails 5.2. Our webpack configuration or version didn't change during the Rails upgrade. Everything is working in development mode and we only see this issue when running Error message01 ERROR in ./app/javascript/packs/activity/ActivityFeed.jsx 01 Module build failed: ReferenceError: [BABEL] /home/deployer/sites/staging.lha-ignite/releases/20180412141715/app/javascript/packs/activity/ActivityFeed.jsx: Unknown option: /home/deployer/sites/staging.lha-ignite/releases/20180412141715/node_modules/react/index.js.Children. Check out http://babeljs.io/docs/usage/options/ for more information about options. 01 01 A common cause of this error is the presence of a configuration options object without the corresponding preset name. Example: 01 01 Invalid: 01 `{ presets: [{option: value}] }` 01 Valid: 01 `{ presets: [['presetName', {option: value}]] }` 01 01 For more detailed information on preset configuration, please see http://babeljs.io/docs/plugins/#pluginpresets-options. (While processing preset: "/home/deployer/sites/staging.lha-ignite/releases/20180412141715/node_modules/react/index.js") 01 at Logger.error (/home/deployer/sites/staging.lha-ignite/releases/20180412141715/node_modules/babel-core/lib/transformation/file/logger.js:41:11) 01 at OptionManager.mergeOptions (/home/deployer/sites/staging.lha-ignite/releases/20180412141715/node_modules/babel-core/lib/transformation/file/options/option-manager.js:226:20) 01 at /home/deployer/sites/staging.lha-ignite/releases/20180412141715/node_modules/babel-core/lib/transformation/file/options/option-manager.js:265:14 01 at /home/deployer/sites/staging.lha-ignite/releases/20180412141715/node_modules/babel-core/lib/transformation/file/options/option-manager.js:323:22 01 at Array.map (native) 01 at OptionManager.resolvePresets (/home/deployer/sites/staging.lha-ignite/releases/20180412141715/node_modules/babel-core/lib/transformation/file/options/option-manager.js:275:20) 01 at OptionManager.mergePresets (/home/deployer/sites/staging.lha-ignite/releases/20180412141715/node_modules/babel-core/lib/transformation/file/options/option-manager.js:264:10) 01 at OptionManager.mergeOptions (/home/deployer/sites/staging.lha-ignite/releases/20180412141715/node_modules/babel-core/lib/transformation/file/options/option-manager.js:249:14) 01 at OptionManager.init (/home/deployer/sites/staging.lha-ignite/releases/20180412141715/node_modules/babel-core/lib/transformation/file/options/option-manager.js:368:12) 01 at File.initOptions (/home/deployer/sites/staging.lha-ignite/releases/20180412141715/node_modules/babel-core/lib/transformation/file/index.js:212:65) 01 at new File (/home/deployer/sites/staging.lha-ignite/releases/20180412141715/node_modules/babel-core/lib/transformation/file/index.js:135:24) 01 at Pipeline.transform (/home/deployer/sites/staging.lha-ignite/releases/20180412141715/node_modules/babel-core/lib/transformation/pipeline.js:46:16) 01 at transpile (/home/deployer/sites/staging.lha-ignite/releases/20180412141715/node_modules/babel-loader/lib/index.js:50:20) 01 at /home/deployer/sites/staging.lha-ignite/releases/20180412141715/node_modules/babel-loader/lib/fs-cache.js:118:18 01 at ReadFileContext.callback (/home/deployer/sites/staging.lha-ignite/releases/20180412141715/node_modules/babel-loader/lib/fs-cache.js:31:21) 01 at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:367:13) .babelrc
package.json
|
@codebycliff see @dmfrancisco comment above, that's the fix I had to do for my scenario:
So, because you reference the And if you would be deploying on heroku (like we do) you don't even need to add the nodejs buildpack (which takes a bit extra time during deploy to go through). |
@rcugut Thank you. I had to move @gauravtiwari Is this the intended behavior? Or just a workaround for the timebeing? |
@codebycliff Yep that correct since webpacker depends on all these dependencies. Obviously, it doesn't directly use them in production code but to actually build the bundles in the production environment when deploying to Heroku or other environments. If you put any direct dependencies of webpacker inside dev dependencies yarn won't install them since on Heroku The other way is to compile deps locally and then push them to production (if you want to keep them under dev dependencies section) |
Out of the box webpacker installer installs these deps under dependencies section: https://github.com/rails/webpacker/blob/master/lib/install/react.rb#L29 |
Perfect. Thanks for your reply. |
While deploy to Heroku, during Webpacker compiling assets, I get this error message
Main error
./app/javascript/packs/application.js
Full log
Some more info
$ NODE_ENV=production RAILS_ENV=production rails assets:precompile --trace
works fine in local machine.The text was updated successfully, but these errors were encountered: