`mix assets.deploy` fails due to ESBuild assets

I’m working with Phoenix 1.7 and Docker fails at the step RUN mix.assets.deploy when deploying to fly (mix assets.deploy) works locally.

0.973
0.973 14:51:47.026 [debug] Downloading esbuild from https://registry.npmjs.org/@esbuild/linux-x64/0.17.11
1.517 ✘ [ERROR] Could not resolve "@mapbox/search-js-web"
1.517
1.517     js/maps.js:1:33:
1.517       1 │ import { autofill, config } from '@mapbox/search-js-web'
1.517         ╵                                  ~~~~~~~~~~~~~~~~~~~~~~~
1.517
1.517   You can mark the path "@mapbox/search-js-web" as external to exclude it from the bundle, which will remove this error.
1.517
1.536 1 error
1.552 ** (Mix) `mix esbuild postbox --minify` exited with 1

I installed the package with npm install @mapbox/search-js-web --save it’s listed in 'assets/ package-lock.json. Then I'm importing it from assets/js/maps.jswith:import { autofill, config } from ‘@mapbox/search-js-web’` seems to be standard JS stuff. What am I missing?

The Dockerfile in the Phoenix docs doesn’t include using npm assets.

Here’s a thread which shows what you need to add:

2 Likes