frappe: esbuild.js path[0] argument must be of type string. Received undefined

Description of the issue

I believe that erpnext is a string but I get an error as it isn’t :

$ pwd
/var/www/dokos/dokos-bench-folder/apps/erpnext
$ node
Welcome to Node.js v18.19.0.
Type ".help" for more information.
> .exit
$ node /var/www/dokos/dokos-bench-folder/apps/frappe/esbuild/esbuild.js --production --apps erpnext --run-build-command
 ERROR  There were some problems during build

TypeError [ERR_INVALID_ARG_TYPE]: The "paths[0]" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:405:5)
    at validateString (node:internal/validators:162:11)
    at Object.resolve (node:path:1097:7)
    at get_all_files_to_build (/var/www/dokos/dokos-bench-folder/apps/frappe/esbuild/esbuild.js:233:9)
    at build_assets_for_apps (/var/www/dokos/dokos-bench-folder/apps/frappe/esbuild/esbuild.js:175:5)
    at execute (/var/www/dokos/dokos-bench-folder/apps/frappe/esbuild/esbuild.js:107:19)
    at Object.<anonymous> (/var/www/dokos/dokos-bench-folder/apps/frappe/esbuild/esbuild.js:92:1)
    at Module._compile (node:internal/modules/cjs/loader:1356:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
    at Module.load (node:internal/modules/cjs/loader:1197:32)
Terminated

Context information (for bug reports)

Output of bench version

frappe 4.17.0

Stacktrace / full error message

2024-05-06 21:52:01,121: DEBUG - yarn run v1.22.22
2024-05-06 21:52:01,227: DEBUG - $ node esbuild --production --apps erpnext --run-build-command
2024-05-06 21:52:02,970: WARNING -  ERROR  There were some problems during build
2024-05-06 21:52:02,973: DEBUG - 
2024-05-06 21:52:02,975: DEBUG - TypeError [ERR_INVALID_ARG_TYPE]: The "paths[0]" argument must be of type string. Received undefined
2024-05-06 21:52:02,975: DEBUG -     at new NodeError (node:internal/errors:405:5)
2024-05-06 21:52:02,975: DEBUG -     at validateString (node:internal/validators:162:11)
2024-05-06 21:52:02,975: DEBUG -     at Object.resolve (node:path:1097:7)
2024-05-06 21:52:02,975: DEBUG -     at get_all_files_to_build (/var/www/dokos/dokos-bench-folder/apps/frappe/esbuild/esbuild.js:233:9)
2024-05-06 21:52:02,976: DEBUG -     at build_assets_for_apps (/var/www/dokos/dokos-bench-folder/apps/frappe/esbuild/esbuild.js:175:5)
2024-05-06 21:52:02,976: DEBUG -     at execute (/var/www/dokos/dokos-bench-folder/apps/frappe/esbuild/esbuild.js:107:19)
2024-05-06 21:52:02,976: DEBUG -     at Object.<anonymous> (/var/www/dokos/dokos-bench-folder/apps/frappe/esbuild/esbuild.js:92:1)
2024-05-06 21:52:02,976: DEBUG -     at Module._compile (node:internal/modules/cjs/loader:1364:14)
2024-05-06 21:52:02,976: DEBUG -     at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
2024-05-06 21:52:02,976: DEBUG -     at Module.load (node:internal/modules/cjs/loader:1203:32)
2024-05-06 21:52:02,983: WARNING - Terminated
2024-05-06 21:52:03,058: WARNING - error Command failed with exit code 143.
2024-05-06 21:52:03,071: DEBUG - info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
2024-05-06 21:52:03,167: WARNING - Traceback (most recent call last):
2024-05-06 21:52:03,196: WARNING -   File "<frozen runpy>", line 198, in _run_module_as_main
2024-05-06 21:52:03,197: WARNING -   File "<frozen runpy>", line 88, in _run_code
2024-05-06 21:52:03,208: WARNING -   File "/var/www/dokos/dokos-bench-folder/apps/frappe/frappe/utils/bench_helper.py", line 131, in <module>
2024-05-06 21:52:03,210: WARNING -     main()
2024-05-06 21:52:03,212: WARNING -   File "/var/www/dokos/dokos-bench-folder/apps/frappe/frappe/utils/bench_helper.py", line 34, in main
2024-05-06 21:52:03,214: WARNING -     FrappeCommandGroup(commands=commands)(prog_name="bench")
2024-05-06 21:52:03,215: WARNING -   File "/var/www/dokos/dokos-bench-folder/env/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
2024-05-06 21:52:03,219: WARNING -     return self.main(*args, **kwargs)
2024-05-06 21:52:03,220: WARNING -            ^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-05-06 21:52:03,238: WARNING -   File "/var/www/dokos/dokos-bench-folder/env/lib/python3.11/site-packages/click/core.py", line 1078, in main
2024-05-06 21:52:03,238: WARNING -     rv = self.invoke(ctx)
2024-05-06 21:52:03,242: WARNING -          ^^^^^^^^^^^^^^^^
2024-05-06 21:52:03,245: WARNING -   File "/var/www/dokos/dokos-bench-folder/env/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
2024-05-06 21:52:03,251: WARNING -     return _process_result(sub_ctx.command.invoke(sub_ctx))
2024-05-06 21:52:03,280: WARNING -                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-05-06 21:52:03,281: WARNING -   File "/var/www/dokos/dokos-bench-folder/env/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
2024-05-06 21:52:03,286: WARNING -     return _process_result(sub_ctx.command.invoke(sub_ctx))
2024-05-06 21:52:03,295: WARNING -                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-05-06 21:52:03,296: WARNING -   File "/var/www/dokos/dokos-bench-folder/env/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
2024-05-06 21:52:03,300: WARNING -     return ctx.invoke(self.callback, **ctx.params)
2024-05-06 21:52:03,309: WARNING -            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-05-06 21:52:03,309: WARNING -   File "/var/www/dokos/dokos-bench-folder/env/lib/python3.11/site-packages/click/core.py", line 783, in invoke
2024-05-06 21:52:03,310: WARNING -     return __callback(*args, **kwargs)
2024-05-06 21:52:03,316: WARNING -            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
2024-05-06 21:52:03,319: WARNING -   File "/var/www/dokos/dokos-bench-folder/apps/frappe/frappe/commands/utils.py", line 69, in build
2024-05-06 21:52:03,326: WARNING -     bundle(
2024-05-06 21:52:03,336: WARNING -   File "/var/www/dokos/dokos-bench-folder/apps/frappe/frappe/build.py", line 257, in bundle
2024-05-06 21:52:03,336: WARNING -     frappe.commands.popen(command, cwd=frappe_app_path, env=get_node_env(), raise_err=True)
2024-05-06 21:52:03,339: WARNING -   File "/var/www/dokos/dokos-bench-folder/apps/frappe/frappe/commands/__init__.py", line 97, in popen
2024-05-06 21:52:03,340: WARNING -     raise subprocess.CalledProcessError(return_, command)
2024-05-06 21:52:03,344: WARNING - subprocess.CalledProcessError: Command 'yarn run production --apps erpnext --run-build-command' returned non-zero exit status 143.

OS version / distribution, Frappe install method, etc. Debian 12

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 17 (17 by maintainers)

Most upvoted comments

I thought that would install it in the bench’s Python virtual environment.

bench/env/bin/activate
bench/env/bin/python -m pip install --upgrade -e  bench/apps/erpnext

You have to activate the virtualenv first, which sets the VIRTUAL_ENV, PYTHONHOME, … environment variables.

I believe that your bench/sites/apps.txt file is incomplete. It should look like this, at least:

frappe
erpnext

https://github.com/frappe/frappe/blob/f8abd09ab91d0634badc1197626789169839c365/esbuild/utils.js#L70-L77

@Thatoo The build command is provided by the frappe app, and is not a built-in in bench.