npm run build - Could not resolve "./resources/js/*.{js,mjs}" #2703

Closed
opened 2026-02-05 04:51:32 +03:00 by OVERLORD · 6 comments
Owner

Originally created by @philjak on GitHub (Mar 11, 2022).

Describe the Bug

Since the latest change of the package.json, npm run build failes with the error:

✘ [ERROR] Could not resolve "./resources/js/*.{js,mjs}"

  It looks like you are trying to use glob syntax (i.e. "*") with esbuild. This syntax is typically
  handled by your shell, and isn't handled by esbuild itself. You must expand glob syntax first
  before passing your paths to esbuild.

1 error
npm ERR! code 1
npm ERR! path /var/www/app
npm ERR! command failed
npm ERR! command sh -c NODE_ENV=production esbuild --bundle ./resources/js/*.{js,mjs} --outdir=public/dist/ --sourcemap --target=es2020 --main-fields=module,main --minify --format=esm

Changing the bundle parameter to --bundle ./resources/js/*.js fixes this issue.

Steps to Reproduce

Go into installation
type npm run build

Expected Behaviour

> NODE_ENV=production esbuild --bundle ./resources/js/*.js --outdir=public/dist/ --sourcemap --target=es2020 --main-fields=module,main --minify --format=esm


  public/dist/app.js      362.6kb
  public/dist/app.js.map    1.2mb

⚡ Done in 100ms

Screenshots or Additional Context

No response

Browser Details

No response

Exact BookStack Version

v22.02-dev

PHP Version

No response

Hosting Environment

Docker image php:7.4-apache

Originally created by @philjak on GitHub (Mar 11, 2022). ### Describe the Bug Since the latest change of the ``package.json``, ``npm run build`` failes with the error: ``` ✘ [ERROR] Could not resolve "./resources/js/*.{js,mjs}" It looks like you are trying to use glob syntax (i.e. "*") with esbuild. This syntax is typically handled by your shell, and isn't handled by esbuild itself. You must expand glob syntax first before passing your paths to esbuild. 1 error npm ERR! code 1 npm ERR! path /var/www/app npm ERR! command failed npm ERR! command sh -c NODE_ENV=production esbuild --bundle ./resources/js/*.{js,mjs} --outdir=public/dist/ --sourcemap --target=es2020 --main-fields=module,main --minify --format=esm ``` Changing the bundle parameter to ``--bundle ./resources/js/*.js`` fixes this issue. ### Steps to Reproduce Go into installation type ``npm run build`` ### Expected Behaviour ``` > NODE_ENV=production esbuild --bundle ./resources/js/*.js --outdir=public/dist/ --sourcemap --target=es2020 --main-fields=module,main --minify --format=esm public/dist/app.js 362.6kb public/dist/app.js.map 1.2mb ⚡ Done in 100ms ``` ### Screenshots or Additional Context _No response_ ### Browser Details _No response_ ### Exact BookStack Version v22.02-dev ### PHP Version _No response_ ### Hosting Environment Docker image ``php:7.4-apache``
OVERLORD added the 🐛 Bug label 2026-02-05 04:51:32 +03:00
Author
Owner

@Elliyos commented on GitHub (Mar 11, 2022):

Also having this issue. Read somewhere that it's a problem with building on Windows. Replacing the bundle parameter with the suggested change doesn't work for me either.

@Elliyos commented on GitHub (Mar 11, 2022): Also having this issue. Read somewhere that it's a problem with building on Windows. Replacing the bundle parameter with the suggested change doesn't work for me either.
Author
Owner

@philjak commented on GitHub (Mar 11, 2022):

@Elliyos did you change those the corresponding line in package.json? There are two lines, one for dev and one for prod.

@philjak commented on GitHub (Mar 11, 2022): @Elliyos did you change those the corresponding line in ``package.json``? There are two lines, one for ``dev`` and one for ``prod``.
Author
Owner

@Elliyos commented on GitHub (Mar 11, 2022):

@philjak Yes, sadly. I specifically changed the dev build parameter which is what I'm working with currently :(

@Elliyos commented on GitHub (Mar 11, 2022): @philjak Yes, sadly. I specifically changed the dev build parameter which is what I'm working with currently :(
Author
Owner

@philjak commented on GitHub (Mar 13, 2022):

Ok, the issue seems to be that by default (even with export SHELL=/bin/bash) that /bin/sh is used by default, which can not handle the {js,mjs}.

Defining the script shell with the following command solved this issue:

npm config set script-shell /bin/bash

@Elliyos In your case, if you're using windows, this could fix your issue (you may need to adjust the path to your bash.exe):
npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"

Best,
Philip

@philjak commented on GitHub (Mar 13, 2022): Ok, the issue seems to be that by default (even with ``export SHELL=/bin/bash``) that ``/bin/sh`` is used by default, which can not handle the ``{js,mjs}``. Defining the script shell with the following command solved this issue: ``npm config set script-shell /bin/bash`` @Elliyos In your case, if you're using windows, this could fix your issue (you may need to adjust the path to your bash.exe): ``npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"`` Best, Philip
Author
Owner

@ssddanbrown commented on GitHub (Apr 10, 2022):

Re-opening until we update the syntax to not be bash specific.

@ssddanbrown commented on GitHub (Apr 10, 2022): Re-opening until we update the syntax to not be bash specific.
Author
Owner

@ssddanbrown commented on GitHub (Apr 13, 2022):

Within 27339079f7 I've made this build use system/shell agnostic NodeJS functions for file/directory location to avoid such issues.

@ssddanbrown commented on GitHub (Apr 13, 2022): Within 27339079f7dd7b6910d4adff1725ea1e89623130 I've made this build use system/shell agnostic NodeJS functions for file/directory location to avoid such issues.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#2703