[Solved] TypeError: this.getOptions is not a function error while using coffee-loader on Rails 6.1

Article Mashpy Rahman


Problem:

I wanted to start a new project on rails with coffee script. So I run these commands -

rails new rails6
rails webpacker:install:coffee

When I started webpack dev server then it unable to compile correctly and getting this error - 

ERROR in ./app/javascript/packs/hello_coffee.coffee
Module build failed (from ./node_modules/coffee-loader/dist/cjs.js):
TypeError: this.getOptions is not a function
    at Object.loader (/Users/iwan/dev/rails/rails6/node_modules/coffee-loader/dist/index.js:21:24)
ℹ 「wdm」: Failed to compile.


Solution:

To solve this problem you can downgrade coffee-loader to the version 1.0.1

Chnage the package.json version from

"coffee-loader": "^2.0.0",

to

"coffee-loader": "1.0.1",

After the run this command - 

yarn install --check-files

Hope this will solve the problem. If not please comment on the below.


Thank you for reading the article.