auvred / prettier-pnp

Run Prettier with plugins without installing them manually
MIT License
4 stars 1 forks source link

not work on bun & ubuntu 23 #12

Open i18nsite opened 6 months ago

i18nsite commented 6 months ago
❯ bun x prettier-pnp --quiet --log-level error --pnp prettier-plugin-toml --stdin-filepath  Cargo.toml
[error] Cargo.toml: Error: Cannot find package 'prettier-plugin-toml' imported from /root/i18n/in/tran_ext/noop.js
[error]     at __node_internal_ (file:///opt/bun/install/global/node_modules/prettier/index.mjs:17857:11)
[error]     at new NodeError (file:///opt/bun/install/global/node_modules/prettier/index.mjs:17822:5)
[error]     at packageResolve (file:///opt/bun/install/global/node_modules/prettier/index.mjs:18802:9)
[error]     at moduleResolve (file:///opt/bun/install/global/node_modules/prettier/index.mjs:18834:20)
[error]     at defaultResolve (file:///opt/bun/install/global/node_modules/prettier/index.mjs:18921:16)
[error]     at resolve2 (file:///opt/bun/install/global/node_modules/prettier/index.mjs:18938:12)
[error]     at importFromFile (file:///opt/bun/install/global/node_modules/prettier/index.mjs:18953:16)
[error]     at importFromDirectory (file:///opt/bun/install/global/node_modules/prettier/index.mjs:23905:10)
[error]     at importPlugin (file:///opt/bun/install/global/node_modules/prettier/index.mjs:23917:12)
[error]     at async loadPluginWithoutCache (file:///opt/bun/install/global/node_modules/prettier/index.mjs:23921:18)
[error]     at async Promise.all (index 0)
[error]     at async Promise.all (index 1)
[error]     at async file:///opt/bun/install/global/node_modules/prettier/index.mjs:24183:17
[error]     at async getContextOptions (file:///opt/bun/install/global/node_modules/prettier/internal/cli.mjs:4881:23)
[error]     at async Context.pushContextPlugins (file:///opt/bun/install/global/node_modules/prettier/internal/cli.mjs:5770:21)
[error]     at async getOptionsForFile (file:///opt/bun/install/global/node_modules/prettier/internal/cli.mjs:6364:5)
[error]     at async formatStdin (file:///opt/bun/install/global/node_modules/prettier/internal/cli.mjs:6580:21)
[error]     at async main (file:///opt/bun/install/global/node_modules/prettier/internal/cli.mjs:7077:5)
[error]     at async Module.run (file:///opt/bun/install/global/node_modules/prettier/internal/cli.mjs:7027:5)
[error]     at async run (file:///opt/bun/install/global/node_modules/prettier-pnp/dist/bin.js:238:3)
❯ bun x prettier-pnp --log-level error --pnp prettier-plugin-toml --stdin-filepath  Cargo.toml

----- Already installed ----

 - prettier-plugin-toml

----- Running prettier -----

[error] Cargo.toml: Error: Cannot find package 'prettier-plugin-toml' imported from /root/i18n/in/tran_ext/noop.js
[error]     at __node_internal_ (file:///opt/bun/install/global/node_modules/prettier/index.mjs:17857:11)
[error]     at new NodeError (file:///opt/bun/install/global/node_modules/prettier/index.mjs:17822:5)
[error]     at packageResolve (file:///opt/bun/install/global/node_modules/prettier/index.mjs:18802:9)
[error]     at moduleResolve (file:///opt/bun/install/global/node_modules/prettier/index.mjs:18834:20)
[error]     at defaultResolve (file:///opt/bun/install/global/node_modules/prettier/index.mjs:18921:16)
[error]     at resolve2 (file:///opt/bun/install/global/node_modules/prettier/index.mjs:18938:12)
[error]     at importFromFile (file:///opt/bun/install/global/node_modules/prettier/index.mjs:18953:16)
[error]     at importFromDirectory (file:///opt/bun/install/global/node_modules/prettier/index.mjs:23905:10)
[error]     at importPlugin (file:///opt/bun/install/global/node_modules/prettier/index.mjs:23917:12)
[error]     at async loadPluginWithoutCache (file:///opt/bun/install/global/node_modules/prettier/index.mjs:23921:18)
[error]     at async Promise.all (index 0)
[error]     at async Promise.all (index 1)
[error]     at async file:///opt/bun/install/global/node_modules/prettier/index.mjs:24183:17
[error]     at async getContextOptions (file:///opt/bun/install/global/node_modules/prettier/internal/cli.mjs:4881:23)
[error]     at async Context.pushContextPlugins (file:///opt/bun/install/global/node_modules/prettier/internal/cli.mjs:5770:21)
[error]     at async getOptionsForFile (file:///opt/bun/install/global/node_modules/prettier/internal/cli.mjs:6364:5)
[error]     at async formatStdin (file:///opt/bun/install/global/node_modules/prettier/internal/cli.mjs:6580:21)
[error]     at async main (file:///opt/bun/install/global/node_modules/prettier/internal/cli.mjs:7077:5)
[error]     at async Module.run (file:///opt/bun/install/global/node_modules/prettier/internal/cli.mjs:7027:5)
[error]     at async run (file:///opt/bun/install/global/node_modules/prettier-pnp/dist/bin.js:238:3)
auvred commented 6 months ago

Could you please share some info to help me reproduce this issue? At least output of npx envinfo --system --binaries? I tried to run the same command in container with ubuntu:23.04 image and the following tool versions:

  Binaries:
    Node: 20.12.2 - ~/.nvm/versions/node/v20.12.2/bin/node
    npm: 10.5.0 - ~/.nvm/versions/node/v20.12.2/bin/npm
    bun: 1.1.5 - ~/.bun/bin/bun

The prettier-plugin-toml was successfully installed and prettier ran without any errors.

i18nsite commented 6 months ago

node is install use https://crates.io/crates/rtx-cli

❯ bun x prettier-pnp --log-level error --pnp prettier-plugin-toml --stdin-filepath  Cargo.toml

----- Already installed ----

 - prettier-plugin-toml

----- Running prettier -----

[error] Cargo.toml: Error: Cannot find package 'prettier-plugin-toml' imported from /root/i18n/in/noop.js
[error]     at __node_internal_ (file:///opt/bun/install/global/node_modules/prettier/index.mjs:17857:11)
[error]     at new NodeError (file:///opt/bun/install/global/node_modules/prettier/index.mjs:17822:5)
[error]     at packageResolve (file:///opt/bun/install/global/node_modules/prettier/index.mjs:18802:9)
[error]     at moduleResolve (file:///opt/bun/install/global/node_modules/prettier/index.mjs:18834:20)
[error]     at defaultResolve (file:///opt/bun/install/global/node_modules/prettier/index.mjs:18921:16)
[error]     at resolve2 (file:///opt/bun/install/global/node_modules/prettier/index.mjs:18938:12)
[error]     at importFromFile (file:///opt/bun/install/global/node_modules/prettier/index.mjs:18953:16)
[error]     at importFromDirectory (file:///opt/bun/install/global/node_modules/prettier/index.mjs:23905:10)
[error]     at importPlugin (file:///opt/bun/install/global/node_modules/prettier/index.mjs:23917:12)
[error]     at async loadPluginWithoutCache (file:///opt/bun/install/global/node_modules/prettier/index.mjs:23921:18)
[error]     at async Promise.all (index 0)
[error]     at async Promise.all (index 1)
[error]     at async file:///opt/bun/install/global/node_modules/prettier/index.mjs:24183:17
[error]     at async getContextOptions (file:///opt/bun/install/global/node_modules/prettier/internal/cli.mjs:4881:23)
[error]     at async Context.pushContextPlugins (file:///opt/bun/install/global/node_modules/prettier/internal/cli.mjs:5770:21)
[error]     at async getOptionsForFile (file:///opt/bun/install/global/node_modules/prettier/internal/cli.mjs:6364:5)
[error]     at async formatStdin (file:///opt/bun/install/global/node_modules/prettier/internal/cli.mjs:6580:21)
[error]     at async main (file:///opt/bun/install/global/node_modules/prettier/internal/cli.mjs:7077:5)
[error]     at async Module.run (file:///opt/bun/install/global/node_modules/prettier/internal/cli.mjs:7027:5)
[error]     at async run (file:///opt/bun/install/global/node_modules/prettier-pnp/dist/bin.js:238:3)
(node:281000) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
❯ npx envinfo --system --binaries
Need to install the following packages:
envinfo@7.12.0
Ok to proceed? (y) y

  System:
    OS: Linux 6.5 Ubuntu 23.10 23.10 (Mantic Minotaur)
    CPU: (8) x64 AMD EPYC 7282 16-Core Processor
    Memory: 27.10 GB / 29.37 GB
    Container: Yes
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.0.0 - /opt/rtx/installs/node/22.0.0/bin/node
    Yarn: 1.22.22 - /opt/rtx/installs/node/22.0.0/bin/yarn
    npm: 10.5.1 - /opt/rtx/installs/node/22.0.0/bin/npm
    pnpm: 9.0.6 - /opt/rtx/installs/node/22.0.0/bin/pnpm
    bun: 1.1.4 - /opt/bun/bin/bun

❯ bunx envinfo --system --binaries

  System:
    OS: Linux 6.5 Ubuntu 23.10 23.10 (Mantic Minotaur)
    CPU: (8) x64 AMD EPYC 7282 16-Core Processor
    Memory: 27.16 GB / 29.37 GB
    Container: Yes
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.0.0 - /opt/rtx/installs/node/22.0.0/bin/node
    Yarn: 1.22.22 - /opt/rtx/installs/node/22.0.0/bin/yarn
    npm: 10.5.1 - /opt/rtx/installs/node/22.0.0/bin/npm
    pnpm: 9.0.6 - /opt/rtx/installs/node/22.0.0/bin/pnpm
    bun: 1.1.4 - /opt/bun/bin/bun

❯ npx x prettier-pnp --log-level error --pnp prettier-plugin-toml --stdin-filepath  Cargo.toml
npm ERR! could not determine executable to run

npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-04-28T04_13_51_996Z-debug-0.log
❯ npm i -g prettier-pnp

added 3 packages in 1s

2 packages are looking for funding
  run `npm fund` for details
Reshimming rtx 22.0.0...
❯ npx x prettier-pnp --log-level error --pnp prettier-plugin-toml --stdin-filepath  Cargo.toml
npm ERR! could not determine executable to run

npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-04-28T04_14_07_870Z-debug-0.log
❯ which bun
/opt/bun/bin/bun
❯ which npm
/opt/rtx/installs/node/22.0.0/bin/npm
❯ which npx
/opt/rtx/installs/node/22.0.0/bin/npx
❯ bun upgrade
Bun v1.1.5 is out! You're on v1.1.4
[2.89s] Upgraded.

Welcome to Bun v1.1.5!

Report any bugs:

    https://github.com/oven-sh/bun/issues

What's new:

    https://github.com/oven-sh/bun/releases/tag/bun-v1.1.5

Changelog:

    https://github.com/oven-sh/bun/compare/bun-v1.1.4...bun-v1.1.5
❯
❯
❯ which npm
❯ bun x prettier-pnp --log-level error --pnp prettier-plugin-toml --stdin-filepath  Cargo.toml

---- Installing plugins ----

 - prettier-plugin-toml

added 4 packages, and audited 5 packages in 3s

2 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

----- Running prettier -----

[error] Cargo.toml: Error: Cannot find package 'prettier-plugin-toml' imported from /root/i18n/in/noop.js
[error]     at __node_internal_ (file:///opt/rtx/installs/node/22.0.0/lib/node_modules/prettier-pnp/node_modules/prettier/index.mjs:17857:11)
[error]     at new NodeError (file:///opt/rtx/installs/node/22.0.0/lib/node_modules/prettier-pnp/node_modules/prettier/index.mjs:17822:5)
[error]     at packageResolve (file:///opt/rtx/installs/node/22.0.0/lib/node_modules/prettier-pnp/node_modules/prettier/index.mjs:18802:9)
[error]     at moduleResolve (file:///opt/rtx/installs/node/22.0.0/lib/node_modules/prettier-pnp/node_modules/prettier/index.mjs:18834:20)
[error]     at defaultResolve (file:///opt/rtx/installs/node/22.0.0/lib/node_modules/prettier-pnp/node_modules/prettier/index.mjs:18921:16)
[error]     at resolve2 (file:///opt/rtx/installs/node/22.0.0/lib/node_modules/prettier-pnp/node_modules/prettier/index.mjs:18938:12)
[error]     at importFromFile (file:///opt/rtx/installs/node/22.0.0/lib/node_modules/prettier-pnp/node_modules/prettier/index.mjs:18953:16)
[error]     at importFromDirectory (file:///opt/rtx/installs/node/22.0.0/lib/node_modules/prettier-pnp/node_modules/prettier/index.mjs:23905:10)
[error]     at importPlugin (file:///opt/rtx/installs/node/22.0.0/lib/node_modules/prettier-pnp/node_modules/prettier/index.mjs:23917:12)
[error]     at async loadPluginWithoutCache (file:///opt/rtx/installs/node/22.0.0/lib/node_modules/prettier-pnp/node_modules/prettier/index.mjs:23921:18)
[error]     at async Promise.all (index 0)
[error]     at async Promise.all (index 1)
[error]     at async file:///opt/rtx/installs/node/22.0.0/lib/node_modules/prettier-pnp/node_modules/prettier/index.mjs:24183:17
[error]     at async getContextOptions (file:///opt/rtx/installs/node/22.0.0/lib/node_modules/prettier-pnp/node_modules/prettier/internal/cli.mjs:4881:23)
[error]     at async Context.pushContextPlugins (file:///opt/rtx/installs/node/22.0.0/lib/node_modules/prettier-pnp/node_modules/prettier/internal/cli.mjs:5770:21)
[error]     at async getOptionsForFile (file:///opt/rtx/installs/node/22.0.0/lib/node_modules/prettier-pnp/node_modules/prettier/internal/cli.mjs:6364:5)
[error]     at async formatStdin (file:///opt/rtx/installs/node/22.0.0/lib/node_modules/prettier-pnp/node_modules/prettier/internal/cli.mjs:6580:21)
[error]     at async main (file:///opt/rtx/installs/node/22.0.0/lib/node_modules/prettier-pnp/node_modules/prettier/internal/cli.mjs:7077:5)
[error]     at async Module.run (file:///opt/rtx/installs/node/22.0.0/lib/node_modules/prettier-pnp/node_modules/prettier/internal/cli.mjs:7027:5)
[error]     at async run (file:///opt/rtx/installs/node/22.0.0/lib/node_modules/prettier-pnp/dist/bin.js:238:3)
(node:281744) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)