Build Step Failing - npm ci not building out node_modules dir

9 months ago

(disclaimer: first time Railway user, so please pardon me if there is this is mostly a "new to the platform" issue)

PROBLEM:
- deployed a node.js project
- npm ci appears to run, creates a node_modules directory
- build fails because build command bash can't find react-scripts

ERROR MSG:
- sh: 1: react-scripts: not found

DEBUG:
- prepended ls -al ./node_modules to the build command (ls -al ./node_modules && npm run build)
- noticed npm_modules was pretty much empty. output for ls -al:

#13 0.096 drwxr-xr-x 3 root root 4096 Oct 29 09:01 .

Oct 29 05:38:23

#13 0.096 drwxr-xr-x 1 root root 4096 Oct 29 09:38 ..

Oct 29 05:38:23

#13 0.096 drwxr-xr-x 2 root root 4096 Oct 29 09:01 .cache

- prepended npm i to the build command (npm i && npm run build)
- build and deploy works fine now

CONCLUSION:
- not sure why the platform's npm ci does not build out the node_modules folder. my guess is it runs npm ci on the old directory it copied to /app, but i have not investigated this myself

5 Replies

9 months ago

Please do not do npm i in the build command, it is redundant -

If you experience errors after removing that we can work from there, but for now, please remove that.

Attachments


9 months ago

@brody

as previously explained:

1. build step fails without npm i
2. node_modules folder is empty, and after investigating, running npm i before build solves it

if it is meant to work WITHOUT npm i, then something isn't working as expected.

please see attached screenshot of what build looks like without npm i.

Attachments


9 months ago

@brody

thanks for your patience. i solved it
my build works without prepending npm i

PROBLEM
- my build has eslint warnings, which caused the build to fail because CI=true
- i added CI=false to my environment
- default install command npm ci no longer installs

SOLUTION
- added DISABLE_ESLINT_PLUGIN to my env to suppress warnings
- removed CI=false from my env

CONCLUSION
- everything is working as expected
- don't expect npm ci to work if you add CI=false to your environment


9 months ago

I'm glad you solved it, but the actual solution would be to fix the warnings properly, they can cause real issues if left unchecked, ask me how I know haha


8 months ago

cleared all the warnings :)

took about as much time as it did to try working around it.
maybe less.

removed DISABLE_ESLINT_PLUGIN and all is well.

one more detail:

cacheDirectories in my package.json was causing node_modules dir to be cached while empty.

added NO_CACHE=1 to my environment, and now deploys are working as expected