Skip to content

[Bug]: Cannot require() ES Module ~ standalone.mjs in a cycle when Node >=v22.12.0 with Prettier >= 3.5.0 #311

Closed as not planned

Description

@nadhifbeo

Description

after update from 1.15.2 to 1.15.3, prettier not working with caption Cannot require() ES Module /media/hdd/local/project/php/l11-sim/node_modules/prettier/standalone.mjs in a cycle. (from /media/hdd/local/project/php/l11-sim/node_modules/@prettier/plugin-php/standalone.js)

Expected Behavior

i want to normal again

Actual Behavior

this plugin not work after update

Additional Context

version: 1.15.3
OS: linux debian 12

Activity

  1. rishabkapadia commented on Feb 17, 2025

    @rishabkapadia

    currently downgraded to get going:
    "@shufo/prettier-plugin-blade": "=1.14.1",

    npm update @shufo/prettier-plugin-blade

  2. shufo commented on Feb 18, 2025

    @shufo
    Owner

    Sorry I could not reproduce the error with latest version with prettier 3.5.1

    $ node -v
    v22.11.0
    
    $ npm list | grep prettier
    ├── @shufo/prettier-plugin-blade@1.15.3
    └── prettier@3.5.1
    
    $ cat package.json
    {
      "devDependencies": {
        "@shufo/prettier-plugin-blade": "^1.15.3",
        "prettier": "^3.5.1"
      }
    }
    
    $ cat .prettierrc.json
    {
      "plugins": ["@shufo/prettier-plugin-blade"],
      "overrides": [
        {
          "files": ["*.blade.php"],
          "options": {
            "parser": "blade",
            "tabWidth": 4
          }
        }
      ]
    }
    
    $ ./node_modules/.bin/prettier test.blade.php
    @extends('frontend.layouts.app')
    @section('title') foo
    @endsection
    @section('content')
        <section id="content">
            <div class="container mod-users-pd-h">
                <div class="pf-user-header">
                    <div></div>
                    <p>@lang('users.index')</p>
                </div>
                <div class="pf-users-branch">
                    <ul class="pf-users-branch__list">
                        @foreach ($users as $user)
                            <li>
                                <img src="{{ asset('img/frontend/icon/branch-arrow.svg') }}" alt="branch_arrow">
                                {{ link_to_route('frontend.users.user.show', $users['name'], $users['_id']) }}
                            </li>
                        @endforeach
                    </ul>
                    <div class="pf-users-branch__btn">
                        @can('create', App\Models\User::class)
                            {!! link_to_route('frontend.users.user.create', __('users.create'), [1, 2, 3], ['class' => 'btn']) !!}
                        @endcan
                    </div>
                </div>
            </div>
        </section>
    @endsection
    @section('footer')
    @stop

    @utqinadhif @rishabkapadia
    Can you give how to reproduce the error?

  3. rishabkapadia commented on Feb 18, 2025

    @rishabkapadia

    macOS 14.7.2
    PHP 8.3.14

    node -v
    v23.6.1
    
    npm -v
    11.1.0
    
    ./node_modules/.bin/prettier resources/views/components/guest/nav.blade.php
    [error] Cannot require() ES Module ../Sites/webapp/node_modules/prettier/standalone.mjs in a cycle. (from ../Sites/webapp/node_modules/@prettier/plugin-php/standalone.js)
    
    cat .prettierrc
    {
      "plugins": ["@shufo/prettier-plugin-blade"],
      "overrides": [
        {
          "files": ["*.blade.php"],
          "options": {
            "parser": "blade",
            "tabWidth": 4
          }
        }
      ]
    }
    
    cat package.json | grep prettier
        "@shufo/prettier-plugin-blade": "^1.15.3",
        "prettier": "^3.5.1",
    
    cat package.json
    {
      "private": true,
      "scripts": {
        "dev": "vite",
        "build": "vite build",
        "prepare": "husky"    
      },
      "devDependencies": {
        "@shufo/prettier-plugin-blade": "^1.15.3",
        "@tailwindcss/forms": "^0.5.7",
        "alpinejs": "^3.13.3",
        "autoprefixer": "^10.4.16",
        "axios": "^1.6",
        "husky": "^9.0.0",
        "laravel-vite-plugin": "^1.0.1",
        "postcss": "^8.4.33",
        "postcss-import": "^16.0.0",
        "prettier": "^3.5.1",
        "tailwindcss": "^3.4.1",
        "vite": "^6.1.0"
      }
    }
    
    

    also tried:

    rm -rf node_modules package-lock.json 
    npm install
    
  4. nadhifbeo commented on Feb 18, 2025

    @nadhifbeo
    Author

    macOS 14.7.2 PHP 8.3.14

    node -v
    v23.6.1
    
    npm -v
    11.1.0
    
    ./node_modules/.bin/prettier resources/views/components/guest/nav.blade.php
    [error] Cannot require() ES Module ../Sites/webapp/node_modules/prettier/standalone.mjs in a cycle. (from ../Sites/webapp/node_modules/@prettier/plugin-php/standalone.js)
    
    cat .prettierrc
    {
      "plugins": ["@shufo/prettier-plugin-blade"],
      "overrides": [
        {
          "files": ["*.blade.php"],
          "options": {
            "parser": "blade",
            "tabWidth": 4
          }
        }
      ]
    }
    
    cat package.json | grep prettier
        "@shufo/prettier-plugin-blade": "^1.15.3",
        "prettier": "^3.5.1",
    
    cat package.json
    {
      "private": true,
      "scripts": {
        "dev": "vite",
        "build": "vite build",
        "prepare": "husky"    
      },
      "devDependencies": {
        "@shufo/prettier-plugin-blade": "^1.15.3",
        "@tailwindcss/forms": "^0.5.7",
        "alpinejs": "^3.13.3",
        "autoprefixer": "^10.4.16",
        "axios": "^1.6",
        "husky": "^9.0.0",
        "laravel-vite-plugin": "^1.0.1",
        "postcss": "^8.4.33",
        "postcss-import": "^16.0.0",
        "prettier": "^3.5.1",
        "tailwindcss": "^3.4.1",
        "vite": "^6.1.0"
      }
    }
    

    also tried:

    rm -rf node_modules package-lock.json 
    npm install
    

    Thanks

  5. shufo commented on Feb 18, 2025

    @shufo
    Owner

    Uh I understand, it occurs when combination of node >=v23 with prettier-plugin-blade latest version.

    $ node -v
    v23.6.1
    
    $ ./node_modules/.bin/prettier test.blade.php
    [error] Cannot require() ES Module /home/shuhei/develop/prettier-plugin-blade-test6/node_modules/prettier/standalone.mjs in a cycle. (from /home/shuhei/develop/prettier-plugin-blade-test6/node_modules/@prettier/plugin-php/standalone.js)

    Node v22 with latest version was ok.

  6. changed the title [-][Bug]: Cannot require() ES Module /media/hdd/local/project/php/l11-sim/node_modules/prettier/standalone.mjs in a cycle. (from /media/hdd/local/project/php/l11-sim/node_modules/@prettier/plugin-php/standalone.js)[/-] [+][Bug]: `Cannot require() ES Module ~ standalone.mjs in a cycle` with Node v23 on latest version[/+] on Feb 18, 2025
  7. nadhifbeo commented on Feb 18, 2025

    @nadhifbeo
    Author

    node -v ─╯
    v22.14.0

    ./node_modules/.bin/prettier /media/hdd/local/project/php/l11-sim/resources/views/pdf/display/apm/print/sep.blade.php ─╯
    [error] Cannot require() ES Module /media/hdd/local/project/php/l11-sim/node_modules/prettier/standalone.mjs in a cycle. (from /media/hdd/local/project/php/l11-sim/node_modules/@prettier/plugin-php/standalone.js)

    In my case, i use v22.14.0 but error,

  8. nadhifbeo commented on Feb 18, 2025

    @nadhifbeo
    Author

    Oh i know, before today, before i update my node, the prettier work well, may be error occurs on >=22.14.0

  9. rishabkapadia commented on Feb 18, 2025

    @rishabkapadia

    Uh I understand, it occurs when combination of node >=v23 with prettier-plugin-blade latest version.

    $ node -v
    v23.6.1

    $ ./node_modules/.bin/prettier test.blade.php
    [error] Cannot require() ES Module /home/shuhei/develop/prettier-plugin-blade-test6/node_modules/prettier/standalone.mjs in a cycle. (from /home/shuhei/develop/prettier-plugin-blade-test6/node_modules/@prettier/plugin-php/standalone.js)
    Node v22 with latest version was ok.

    i just tried it with node 22 (& plugin 1.15.3), its not working. i'm on v23 for quite some time (its highly unlikely the cause). faced issues recently (went from 1.13.4 to 1.15.3).

    Got it working by downgrading to 1.13.4 with node 23

  10. shufo commented on Feb 18, 2025

    @shufo
    Owner

    @utqinadhif @rishabkapadia Thanks.

    #311 (comment) was not corret.
    It seems above node >=v22.12.0 got error.

    $ node -v
    v22.12.0
    $ ./node_modules/.bin/prettier test.blade.php
    [error] Cannot require() ES Module /home/shuhei/develop/prettier-plugin-blade-test6/node_modules/prettier/standalone.mjs in a cycle. (from /home/shuhei/develop/prettier-plugin-blade-test6/node_modules/@prettier/plugin-php/standalone.js)

    v22.11.0 is ok

    $ node -v
    v22.11.0
    
    $ ./node_modules/.bin/prettier test.blade.php
    @extends('frontend.layouts.app')
    @section('title') foo
    @endsection
    @section('content')
        <section id="content">
            <div class="container mod-users-pd-h">
                <div class="pf-user-header">
                    <div></div>
                    <p>@lang('users.index')</p>
                </div>
                <div class="pf-users-branch">
                    <ul class="pf-users-branch__list">
                        @foreach ($users as $user)
                            <li>
                                <img src="{{ asset('img/frontend/icon/branch-arrow.svg') }}" alt="branch_arrow">
                                {{ link_to_route('frontend.users.user.show', $users['name'], $users['_id']) }}
                            </li>
                        @endforeach
                    </ul>
                    <div class="pf-users-branch__btn">
                        @can('create', App\Models\User::class)
                            {!! link_to_route('frontend.users.user.create', __('users.create'), [1, 2, 3], ['class' => 'btn']) !!}
                        @endcan
                    </div>
                </div>
            </div>
        </section>
    @endsection
    @section('footer')
    @stop
  11. changed the title [-][Bug]: `Cannot require() ES Module ~ standalone.mjs in a cycle` with Node v23 on latest version[/-] [+][Bug]: `Cannot require() ES Module ~ standalone.mjs in a cycle` when Node >=v22.12.0 with latest version[/+] on Feb 18, 2025
  12. rishabkapadia commented on Feb 18, 2025

    @rishabkapadia

    that worked. thank you.

    note: if you are using brew, i was not able to install a specific version. instead it kept installing the latest patch (v22.13.1). hence had to install 22.11 via nvm

  13. 25 remaining items

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions