kyljmn
Not able to resolve external npm packages in prod
I am using an external node package (export-to-csv) for one of my hooks in my Phoenix project. When I run it locally, it works. When I deploy it to heroku, it deploys. However when I run it in prod I get and error. You can mark the path "export-to-csv" as external to exclude it from the bundle, which will remove this error.
I suspect the problem is with esbuild, but I don’t know of any solution.
Tried checking my assets directory, but for some reason I don’t have a package.json file in it. Not sure if that’s right.
Here are the versions of elixir, phoenix, and esbuild
elixir: 1.12
phoenix 1.6.15
esbuild 0.4
Here are the config relating to esbuild:
config/config.exs
config :esbuild,
version: "0.14.29",
default: [
args:
~w(js/app.js --bundle --target=es2017 --outdir=../priv/static/assets --external:/fonts/* --external:/images/*),
cd: Path.expand("../assets", __DIR__),
env: %{"NODE_PATH" => Path.expand("../deps", __DIR__)}
]
Anyone know how to fix this?
Most Liked
LostKobrakai
Is the node package available when the bundle is created? The default phoenix setup doesn’t include handling of npm packages.
Popular in Questions
Other popular topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #advent-of-code
- #elixirconf-us
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #performance








