lmletham
Hey guys!
I added a JS package to my Phoenix project, specifically TipTap so I could have a text editor. They did not have Phoenix Framework specific install instructions so I used the Vanilla JS instructions and it seems to have worked locally but whenever I try to run fly deploy I get build errors now.
I have checked the following:
-
Tiptap package is correctly installed in the
wordsmith/node_modules/@tiptapfolder -
My esbuild settings in the
config/config.exsfile are set to look inside thenode_modulesfolder: -
My
app.jsfile is importing Tiptap correctly
I assume that my issue is some kind of relative path problem? I’m just not pointing correctly to the node_modules folder? But this is my folder structure and I don’t see anything wrong with the relative paths I have.
If anyone could help point out what the trouble spot is here, I’d greatly appreciate it!
P.S. I forgot to add, I also tried:
- using a relative path to the
node_modulesfolder in theapp.jsimport. That didn’t work. - marking the path as external (as suggested by the error message) but I must not have done it right because that also didn’t fix anything.
Trending in Questions
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security











Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
D4no0
have you checked if you have the dependency in
package.json? the foldernode_modulesusually is added in gitignore.lmletham
Yes, I have. This is what I have in package.json:
I’m not sure I follow what you said about gitignore. I believe the
fly deployshould only be looking at my local files not my github right?D4no0
Dependencies are usually not copied over in the build/deploy environment. Esbuild is also not responsible for installing your dependencies, you have to run
npm installspecifically, how you do that on fly io is beyond my knowledge.lmletham
Hmm, I had already run
npm install. Ran it again just now, this is the result:So I feel like that part is ok?
LostKobrakai
I‘m not sure what you do locally matters. What matters is that those commands are also run when you build the docker images for fly.
dfalling
When I migrated to Fly.io, I had to tweak my project a bit to install NPM packages.
I think this is all I had to patch:
Add npm and nodejs here in Dockerfile:
Add an npm ci install step to
mix.exsassets.deploy:Let me know if this doesn’t work- I may have missed another step I’m not remembering now.
lmletham
Hi!
I did as you suggested and updated my Dockerfile and the mix.exs. I suspect there might be another step to your tweaks because I still got an error (albeit a different one now haha)
I’m not sure why this error is being thrown. I have a
package-lock.jsonfile in the root directory of my app. and it definitely has a lockfileVersion > 1:And the other suggestion from the error has already been done. I ran npm install with version 10.5.0. It seems like maybe
fly deployit is not detecting the existence of mypackage-lock.jsonat all?I’m including the above in case the error jogs more memory and you remember some other small facet I need to implement. Thanks for your previous suggestion!
lmletham
OK. I got it working now. I also posted this question to r/elixir and got a suggestion there:
So I moved
package.json,package-lock.json, and thenode_modulesfolder into myassetsfolder. That seems to have fixed things. Thefly deployran successfully.That poster also pointed out the documentation which I had read, but not clearly understood. It looks like there is a line there in option 2 that says “Call npm inside your assets directory”. I didn’t think that was the option I was using, but it looks like I should have used
npm installfrom the get-go from inside that directory and it would have created thenode_modulesfolder where it needed to go.I also left in the changes that @dfalling suggested, so I’m not sure if that is part of why things are working now, but I’m glad they are. Thanks again everyone.
dfalling
If you want to keep that in the root, you can tweak the
assets.deployto not change the directory: “cmd–cd assetsnpm ci”. Personally I prefer what you’ve done now with keeping the Javascript in theassetsdirectory.dfalling
One other note: I just learned that
npm ciactually installs dev dependencies as well. I’ve updated my build to this:This ensures dev dependencies (eg rollup, prettier, etc.) aren’t included in the prod build.