node_modules
I'm trying to deploy using my build script.
The build script consist in install normally the packages (including the development packages), but after, I need to remove the node_modules file to install only the production package's, but I got the error about .cache folder
#12 1.527 rm: cannot remove 'node_modules/.cache': Device or resource busy
Someone knows a way to reinstall the node_modules only for production?
The current build command:
The "tsup" will convert my TypeScript project to JavaScript project at dist
folder, so I don't need the src
folder anymore.Solution:Jump to solution
its works with some changes
```docker
FROM node:18.17.1-alpine3.18 AS base
FROM base AS build...
45 Replies
Project ID:
N/A
you should not be installing the node modules in the build command
but first, is node_modules in your .gitignore?
of course
i'm trying to reinstall the node_modules to reduce the project size
does the initial build with tsup need dev dependencies?
the tsup is a dev dependencie, I don't need tsup to run the project, just for convert typescript to javascript during the build command
isnt there a trim command that will remove dev deps?
tsup ./src && yarn trim --dev
i'll try, one moment
dont know if thats a thing, but you get the idea
no no, i just made that up
you need to check for the actual flag and syntax
does command works for yarn v1 (classic)?
again, i dont know it was a pseudo command
did not work
bruh
^
i tryed to run
tsup ./src && rm -rf src && yarn install --prod
but my build time got a lot more seconds^
sure
do you know if pnpm can do it?
npm can
with prune?
npm prune --production
pnpm too
honestly just use npm, ive never seen much of a benefit with yarn or pnpm
nothing new,
#12 2.315 up to date, audited 349 packages in 962ms
, the correct is under of 300 packages
running the following script:
but keeps uploading 235.4MB
project_id: 56101361-0f25-4fa0-acf1-9524a7ab9a3dI mean, is 235 such a big deal?
but for real, what you're trying to do would best be achieved in a multistage dockerfile
yes, i'm think this too
always was 200+ MB
i'll read the docs for the moment to implements dockerfile
just have a Dockerfile in your project and railway will build with a dockerfile, but railway doesn't have any docs on how to write a dockerfile, since there are already so many great resources on that
do you know a documentation to create a Dockerfile? i just know how to use docker compose
i have never used dockerfile before
not off the top of my head, I'm sure you can find plenty of resources on Google though
ok, i'll search is a good size? or i can reduce more?
my project is very small
only theses javascript files (and the prisma orm), and probably is not more than 100mb
or... maybe the prisma is the large size?
what node image are you using?
alpine
let's see the dockerfile
hmm... i'm working around the dockerfile, because it's not copying my dist (generated by yarn build) folder
probably because its in .gitignore file
send the file anyway
also, have you said what kind of app this is yet?
apologies if you have
a common fastify/express backend app
uh yeah that's not gonna work
I'd rewrite that for you, but unfortunately I'm not at my computer right now
no problems bro i'm close too
lol not really tbh
you are using CMD instead of RUN
hey @luci give this a shot, but without seeing your code, i cant promise it will work
Solution
its works with some changes
With a total size of 157.3MB
awesome, glad I could help
thanks bro
no problem!