4

I am getting error "Module build failed: TypeError: this.setDynamic is not a function". What is wrong with my package.json?

The error appears after I update to babel 7:

npx babel-upgrade --write --install

package.json:

{
  "private": true,
  "scripts": {
    // ...
  },
  "devDependencies": {
    "@babel/core": "^7.0.0",
    "@babel/plugin-proposal-class-properties": "^7.0.0",
    "@babel/plugin-proposal-json-strings": "^7.0.0",
    "@babel/plugin-syntax-dynamic-import": "^7.0.0",
    "@babel/plugin-syntax-import-meta": "^7.0.0",
    "@babel/plugin-transform-regenerator": "^7.0.0",
    "@babel/plugin-transform-runtime": "^7.3.4",
    "@babel/preset-env": "^7.0.0",
    "axios": "^0.16.2",
    "bootstrap-sass": "^3.4.1",
    "cross-env": "^5.2.0",
    "jquery": "^3.3.1",
    "laravel-elixir": "^6.0.0-18",
    "laravel-mix": "^1.7.2",
    // ...
  },
  "dependencies": {
    "@babel/runtime": "^7.3.4",
    "babel-loader": "^8.0.0-beta.6",
    "sass": "^1.17.3",
    "vee-validate": "^2.1.7",
    // ...
  }
}

.babelrc :

 {
  "plugins": ["@babel/plugin-transform-runtime"]
 }

Stack trace

ERROR in ./resources/assets/js/app-home.js
Module build failed: TypeError: this.setDynamic is not a function
    at PluginPass.pre (projectpath\node_modules\babel-plugin-transform-runtime\lib\index.js:31:12)
    at transformFile (projectpath\node_modules\@babel\core\lib\transformation\index.js:78:27)
    at runSync (projectpath\node_modules\@babel\core\lib\transformation\index.js:45:3)
    at runAsync (projectpath\node_modules\@babel\core\lib\transformation\index.js:35:14)
    at process.nextTick (projectpath\node_modules\@babel\core\lib\transform.js:34:34)
    at process._tickCallback (internal/process/next_tick.js:61:11)
 @ multi ./resources/assets/js/app-home.js ./resources/assets/sass/app.scss

ERROR in multi ./resources/assets/js/app-home.js ./resources/assets/sass/app.scss
Module not found: Error: Can't resolve 'sass-loader' in 'projectpath'
 @ multi ./resources/assets/js/app-home.js ./resources/assets/sass/app.scss
Zezi Reeds
  • 1,286
  • 1
  • 16
  • 29
  • 1
    This might help you. Seems like almost the same problem. https://github.com/babel/babel-loader/issues/560 – Dhaval Chheda Mar 16 '19 at 13:21
  • Thank you, I've been there already. Did not help – Zezi Reeds Mar 16 '19 at 13:36
  • 1
    It seems your error is because of sass-loader. Try this command "npm install sass-loader --save-dev" – Dhaval Chheda Mar 16 '19 at 14:17
  • Does not solve the this.setDynamic error, unfortunately (it solves the second error though) – Zezi Reeds Mar 16 '19 at 14:47
  • 1
    Can you this post too. https://stackoverflow.com/questions/52901717/vuejs-babel-loader-this-setdynamic-is-not-a-function – Dhaval Chheda Mar 16 '19 at 16:07
  • 1
    Your config and package reference `@babel/plugin-transform-runtime`, but the error mentions `babel-plugin-transform-runtime` so most likely that error is caused by something somewhere else enabling the wrong plugin. The `@babel/` version is the one you want. The `babel-` version is for Babel 6, which is why you get the error. – loganfsmyth Mar 16 '19 at 22:23
  • @DhavalChheda Yep, I've been already as well, did not work – Zezi Reeds Mar 18 '19 at 21:44
  • @loganfsmyth That makes sense. I tried uninstalling babel-plugin-transform-runtime but no effect. Cannot figure out what enables the wrong plugin – Zezi Reeds Mar 18 '19 at 21:44
  • 1
    You'd think someone would solve this after a year. Im getting this as well. – Pwntastic May 07 '20 at 17:09

0 Answers0