VOOZH about

URL: https://qiita.com/hidehiro98/items/fb52be640e82e5a06100

⇱ webpackerを使ったrailsアプリを実行するとき、TypeError: environment.plugins.set is not a functionというエラーが出る #Rails - Qiita


👁 Image
13

Go to list of users who liked

6

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

More than 5 years have passed since last update.

@hidehiro98(Hidehiro Nagaoka)

webpackerを使ったrailsアプリを実行するとき、TypeError: environment.plugins.set is not a functionというエラーが出る

13
Posted at

環境

  • Rails 5.1.5
  • webpacker 3.3.0

現象

Compilation failed:
remote: /tmp/build_074ca0ee678491d6f72035c60cc5f616/config/webpack/environment.js:5
remote: environment.plugins.set('Provide',
remote: ^
remote: TypeError: environment.plugins.set is not a function
remote: at Object.<anonymous> (/tmp/build_074ca0ee678491d6f72035c60cc5f616/config/webpack/environment.js:5:21)
remote: at Module._compile (module.js:643:30)

対策

setではなくappendprependを使う。webpacker 3.3.0でsetがremoveされたため。

Before

config/webpack/environment.js
environment.plugins.set('Provide',
 new webpack.ProvidePlugin({
 $: 'jquery',
 jQuery: 'jquery'
 })
)

After

config/webpack/environment.js
environment.plugins.prepend('Provide',
 new webpack.ProvidePlugin({
 $: 'jquery',
 jQuery: 'jquery'
 })
)

参考

https://github.com/rails/webpacker/issues/1318 https://github.com/rails/webpacker/blob/master/CHANGELOG.md#330---2018-03-03
http://more-caffeine.hatenablog.com/entry/2018/03/05/142450
https://stackoverflow.com/questions/49107725/i-got-webpacker-error-when-running-the-rails-app-typeerror-environment-plugin

13

Go to list of users who liked

6
2

Go to list of comments

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
13

Go to list of users who liked

6