miracle2k / webassets

Asset management for Python web development.
BSD 2-Clause "Simplified" License
921 stars 258 forks source link

Version 2: Couldn't find preset #527

Closed carlosvega closed 1 year ago

carlosvega commented 4 years ago

Hi,

since I use version two I'm getting the following error:

ERROR:webassets.script:Failed, error was: babel: subprocess returned a non-success result code: 1, stdout=, stderr=Error: Couldn't find preset "./node_modules/babel-preset-env" relative to directory "/builds/...

I use babel-preset-env 1.7.0 and babel-cli@6.26.0 I'm not sure how to address, any fix? Should I use babel 7? Thanks

michaeltoohig commented 3 years ago

I'm also having trouble setting up Babel for the first time and seeing the same error.

carlosvega commented 1 year ago

Any news on this?

carlosvega commented 1 year ago

I managed to fix this in the following way:

Install the following packages globally with npm install -g @babel/cli@7.19.3 @babel/core@7.20.5 ├── @babel/cli@7.19.3 ├── @babel/core@7.20.5

For local npm packages, install "@babel/preset-env": "^7.20.2"

Them in python, for Flask-assets 2.0 and webassets 2.0, do.

from flask_assets import Bundle
from webassets.filter import get_filter
import os

babel = get_filter(
    "babel",
   extra_args=[
       "--plugins",
       "./<project_name>/static/vendor/node_modules/@babel/plugin-transform-spread",
   ]
)

Change the path accordingly. In my case the issue was with plugin-transform-spread that has also been included inside @babel package.