rails-new icon indicating copy to clipboard operation
rails-new copied to clipboard

npx missing when using `--js esbuild`

Open excid3 opened this issue 1 year ago • 6 comments

If you run rails-new main --js esbuild, you'll get the following error because npx is not available.

       rails  javascript:install:esbuild
       apply  /usr/local/bundle/gems/jsbundling-rails-1.3.0/lib/install/esbuild/install.rb
       apply    /usr/local/bundle/gems/jsbundling-rails-1.3.0/lib/install/install.rb
    Compile into app/assets/builds
      create      app/assets/builds
      create      app/assets/builds/.keep
      append      app/assets/config/manifest.js
      append      .gitignore
      append      .gitignore
    Add JavaScript include tag in application layout
      insert      app/views/layouts/application.html.erb
    Create default entrypoint in app/javascript/application.js
      create      app/javascript
      create      app/javascript/application.js
    Add default package.json
      create      package.json
    Add bin/dev to start foreman
      create      bin/dev
       apply    /usr/local/bundle/gems/jsbundling-rails-1.3.0/lib/install/install_procfile.rb
    Add default Procfile.dev
      create      Procfile.dev
    Ensure foreman is installed
         run      gem install foreman from "."
Successfully installed foreman-0.88.1
1 gem installed
  Install esbuild
         run    yarn add esbuild from "."
  Add build script
bin/rails aborted!
Rails::Generators::Error: The template [/usr/local/bundle/gems/jsbundling-rails-1.3.0/lib/install/esbuild/install.rb] could not be loaded. Error: No such file or directory - npx (Rails::Generators::Error)


Caused by:
Errno::ENOENT: No such file or directory - npx (Errno::ENOENT)

Tasks: TOP => app:template
(See full trace by running task with --trace)

Since Node isn't installed in the Docker container, Rails can't add the esbuild package with npx.

I'm not sure if this also applies to --js bun or not.

excid3 avatar Jul 16 '24 18:07 excid3