Saleor: Error build-assets - new decorators proposal is not supported yet. You must pass the"legacy": true option

Created on 16 May 2018  路  4Comments  路  Source: mirumee/saleor

What I'm trying to achieve

Install the latest version of Saleor
node -v
v8.11.2
npm -v
5.6.0
...

Steps to reproduce the problem

  1. Following the instalation guide at https://saleor.readthedocs.io/en/latest/gettingstarted/installation-linux.html
  2. When I tried to do the 9th step - Prepare front-end assets with $ npm run build-assets I'm getting the error:
    Module build failed: Error: [BABEL] new decorators proposal is not supported yet. You must pass the"legacy": trueoption to @babel/plugin-proposal-decorators

    What I expected to happen

...Install Saleor without erros in the 9th step

What happened instead/how it failed

ERROR in ./saleor/static/dashboard/js/dashboard.js
Module build failed: Error: [BABEL] /home/toguko/PRINTSCONNECTION/prints_docker/saleor/saleor/static/dashboard/js/dashboard.js: The new decorators proposal is not supported yet. You must pass the "legacy": true option to @babel/plugin-proposal-decorators (While processing: "/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/plugin-proposal-decorators/lib/index.js")
at _default (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/plugin-proposal-decorators/lib/index.js:44:11)
at /home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/helper-plugin-utils/lib/index.js:19:12
at loadDescriptor (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/core/lib/config/full.js:163:14)
at cachedFunction (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/core/lib/config/caching.js:42:19)
at loadPluginDescriptor (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/core/lib/config/full.js:198:28)
at config.plugins.map.descriptor (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/core/lib/config/full.js:64:16)
at Array.map ()
at recurseDescriptors (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/core/lib/config/full.js:63:38)
at loadFullConfig (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/core/lib/config/full.js:106:6)
at process.nextTick (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/core/lib/transform.js:28:33)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)

ERROR in ./saleor/static/dashboard/js/document.js
Module build failed: Error: [BABEL] /home/toguko/PRINTSCONNECTION/prints_docker/saleor/saleor/static/dashboard/js/document.js: The new decorators proposal is not supported yet. You must pass the "legacy": true option to @babel/plugin-proposal-decorators (While processing: "/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/plugin-proposal-decorators/lib/index.js")
at _default (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/plugin-proposal-decorators/lib/index.js:44:11)
at /home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/helper-plugin-utils/lib/index.js:19:12
at loadDescriptor (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/core/lib/config/full.js:163:14)
at cachedFunction (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/core/lib/config/caching.js:42:19)
at loadPluginDescriptor (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/core/lib/config/full.js:198:28)
at config.plugins.map.descriptor (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/core/lib/config/full.js:64:16)
at Array.map ()
at recurseDescriptors (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/core/lib/config/full.js:63:38)
at loadFullConfig (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/core/lib/config/full.js:106:6)
at process.nextTick (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/core/lib/transform.js:28:33)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)

ERROR in ./saleor/static/js/storefront.js
Module build failed: Error: [BABEL] /home/toguko/PRINTSCONNECTION/prints_docker/saleor/saleor/static/js/storefront.js: The new decorators proposal is not supported yet. You must pass the "legacy": true option to @babel/plugin-proposal-decorators (While processing: "/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/plugin-proposal-decorators/lib/index.js")
at _default (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/plugin-proposal-decorators/lib/index.js:44:11)
at /home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/helper-plugin-utils/lib/index.js:19:12
at loadDescriptor (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/core/lib/config/full.js:163:14)
at cachedFunction (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/core/lib/config/caching.js:42:19)
at loadPluginDescriptor (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/core/lib/config/full.js:198:28)
at config.plugins.map.descriptor (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/core/lib/config/full.js:64:16)
at Array.map ()
at recurseDescriptors (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/core/lib/config/full.js:63:38)
at loadFullConfig (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/core/lib/config/full.js:106:6)
at process.nextTick (/home/toguko/PRINTSCONNECTION/prints_docker/saleor/node_modules/@babel/core/lib/transform.js:28:33)
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
`

Most helpful comment

I solved this error changing the two lines below at package.json

"babel": {
    "presets": [
-    "@babel/preset-stage-0",
+    ["@babel/preset-stage-0", { "decoratorsLegacy": true }],
      "@babel/preset-es2015",
      "@babel/preset-react"
    ],
    "plugins": [
      "@babel/plugin-proposal-class-properties",
-    "@babel/plugin-proposal-decorators",
+    ["@babel/plugin-proposal-decorators", { "legacy": true }],
      "@babel/plugin-proposal-object-rest-spread"
    ]
  },

I don't know if this is the best solution, but worked for me.

All 4 comments

I solved this error changing the two lines below at package.json

"babel": {
    "presets": [
-    "@babel/preset-stage-0",
+    ["@babel/preset-stage-0", { "decoratorsLegacy": true }],
      "@babel/preset-es2015",
      "@babel/preset-react"
    ],
    "plugins": [
      "@babel/plugin-proposal-class-properties",
-    "@babel/plugin-proposal-decorators",
+    ["@babel/plugin-proposal-decorators", { "legacy": true }],
      "@babel/plugin-proposal-object-rest-spread"
    ]
  },

I don't know if this is the best solution, but worked for me.

@dominik-zeglen could you take a look at this? I think there was something recently going on with babel decorators

We should not be using decorators in our code. They are not a stable API and the implementations differ (even between Babel and TypeScript).

@toguko Thank you! It works for me!

Was this page helpful?
0 / 5 - 0 ratings