Problem with custom .npmrc file setup

zerkia
TRIAL

6 months ago

Hello

I am working on a frontend implementation and need to set up a custom .npmrc file which is ignored by git, so it's not in the repository by default.

How would I best go about doing this so I can deploy access to the application tools I need access to ?

Solved

0 Replies

zerkia
TRIAL

6 months ago

4cd0f196-cd60-4ec1-bf0d-51e5ec7fdf63


6 months ago

Try setting the engines.node in your package.json


6 months ago

you can also provide a NIXPACKS_NODE_VERSION env var, but you can only set it to major versions: 14, 16, 18, or 20


6 months ago


6 months ago

@Zerkia pinging for visibility


zerkia
TRIAL

6 months ago

I will take a look, thanks 🙂


zerkia
TRIAL

6 months ago

Ended up exposing the file instead and transferring sensitive data as an .env and that seems to have worked.

However, when trying to make an optimized production build, it seems after a while it just gives up and crashes. the error code doesn't really tell me much either that I know of either. Could you perhaps take a look if possible ?


6 months ago

If u send ur build logs here, sure


zerkia
TRIAL

6 months ago

Sure, one moment


zerkia
TRIAL

6 months ago


zerkia
TRIAL

6 months ago

This is the error area, I don't know how to copy the full build log, couldn't see a copy button anywhere


zerkia
TRIAL

6 months ago

this is the start if needed

1330901108977307600


6 months ago

Cntrl K -> Download Logs


6 months ago

Just to make sure, you aren't commiting your node_modules to the repo, right?


zerkia
TRIAL

6 months ago

Nono, it's a company app I need to upload a copy of to my exam. Looking up some StackOverflow posts, it may be the CI seeing the eslint and prettier errors as actual errors


6 months ago

yeah, that's a possibility


zerkia
TRIAL

6 months ago

Trying that real quick, will report back


zerkia
TRIAL

6 months ago

Completely forgot to report back sorry.

Missing some authentication with sentry which my company makes use of. My supervisor asked if skipping the build portion is possible and going directly to the "npm run start" portion of the deployment ?


zerkia
TRIAL

6 months ago

Completely forgot to report back sorry.

Missing some authentication with sentry which my company makes use of. My supervisor asked if skipping the build portion is possible and going directly to the "npm run start" portion of the deployment ?


zerkia
TRIAL

6 months ago

Little update on that: Tried setting the custom build command to "npm run start", but that just seems to have it stuck in "building…" for forever


zerkia
TRIAL

6 months ago

while actually seemingly running


zerkia
TRIAL

6 months ago

Albeit the site does not seems accessible due to it not getting to the deploy stage


6 months ago

you cannot start your app during build


6 months ago

build is for building


zerkia
TRIAL

6 months ago

Yeah I figured, just wanted to try. Is there no way to omit the build stage whatsoever and just have it directly go to "npm run start" or similar ?


6 months ago

you mean omit running npm run build


zerkia
TRIAL

6 months ago

Yes


6 months ago

I obviously don't know much about your project, but are you sure you can skip it? what does the build script actually run?


zerkia
TRIAL

6 months ago

"build": "CI=false react-scripts build && npm run sentry:sourcemaps",


zerkia
TRIAL

6 months ago

sentry being the issue due to auth


6 months ago

you definitely need to run build for react scripts


6 months ago

so you can just replace the build command in the service settings with that


6 months ago

you will also need to copy the Caddyfile and nixpacks.toml from this repo into yours, otherwise you'll be asking Railway to run a development mode server for your app


6 months ago

and sentry probably has some docs about a ci/cd environment


6 months ago

maybe u just miss some extra config?


zerkia
TRIAL

6 months ago

My supervisor suggested removing the sentry part of the build command and running it build + run like it should be


zerkia
TRIAL

6 months ago

I haven't touched sentry ever, so this is out of my depth


6 months ago

please do this now


zerkia
TRIAL

6 months ago

Haven't done that yet, will do so now if still required, just wanted to mention:

It seems to run, deploy and such but then crashes very shortly after, stating:

Starting the development server...

The build failed because the process exited too early. This probably means the system ran out of memory or someone called `kill -9` on the process.

Just wanted to mention it before adding the files, in case I need to do something else as well on the railway server


6 months ago

Are you on railway trial?


6 months ago

or do you have the hobby plan?


6 months ago

this is still needed


zerkia
TRIAL

6 months ago

I have a railway trial, and I'm wroking on the files now


zerkia
TRIAL

6 months ago

trial has 4.82 left


zerkia
TRIAL

6 months ago

It doesn't seem to crash now, after adding the files, but I don't seem to be able to access the page, stating a 502 bad gateway. the railway url is set to run via port 3000


zerkia
TRIAL

6 months ago

1330931445459456000


6 months ago

your target port is wrong


zerkia
TRIAL

6 months ago

Well how do I know what target port is right? locally it ran via 3000


6 months ago

click the edit icon and choose the correct port


zerkia
TRIAL

6 months ago

It does show 8080 (Caddy), I assume that's the one you're referring to ?


zerkia
TRIAL

6 months ago

Page seems to be running now, just need to add the new url to the whitelist for my backend, so keeping this open for another moment, just in case something Railway-relevant pops up. If not, I'll let you guys know, thanks 🙂


zerkia
TRIAL

6 months ago

Does not seem to be talking with the backend properly despite the whitelist. I remember I had a similar issue when trying to deploy the code locally for production, compared to development. Is there any way to have the code running in development on the host at all? Not sure if it's smart or anything of course, but considering I only need to showcase some crud actions that runs through redis and postgresql tomorrow for my exam, would it be possible ?


6 months ago

nope, please do not run a development server, on any cloud server


6 months ago

Does not seem to be talking with the backend properly
please explain more, this amount of information makes it impossible for us to provide support


zerkia
TRIAL

6 months ago

Of course, I'm trying to troubleshoot it myself at the moment, as it seems to potentially be internal, but I'm trying to ensure that, that is the case first


6 months ago

is there a link we can goto to see the error?


zerkia
TRIAL

6 months ago

the error happens on the platform itself when trying to log in to it. my api does not seem to be properly reached, and I'm trying to figure out why that is. It's kinda hard to explain as I'm not sure what causes it. My guess is maybe some development mode vs production mode stuff but I'm (very slowly) trying to get contact with my supervisor to get some answers, as this is not something I've developed, and it's the last thing I need for a hosted application.

I have already updated the various areas that needed updates in regards to postgres, redis, front and backend urls', as well as whitelisting them, so I don't think it's something as simple as a bad url when running the flask api request


6 months ago

have you tried looking at your networking tab in the dev tools for your browser?


zerkia
TRIAL

6 months ago

I have, I see no payload, but the request goes through as a 200. the console showcases a CORS with the api call mentioned


6 months ago

does it go to the correct url though


zerkia
TRIAL

6 months ago

It does not, trying to figure out where to change it now as well


zerkia
TRIAL

6 months ago

Thanks for pointing it out, I'm admittedly a little tunnel visioned atm


6 months ago

are you using a REACT_ env var to set the api url?


zerkia
TRIAL

6 months ago

yes, set as REACTAPPHOSTAPIKEY with a reference to my backend application


zerkia
TRIAL

6 months ago

that is also hosted on railway


zerkia
TRIAL

6 months ago

the one you helped me with yesterday


6 months ago

why is that called an API key instead of a url?


6 months ago

an API key is a completely different thing


zerkia
TRIAL

6 months ago

Don't ask me, I didn't make it. I'm looking at where the apitokens comes from and it's lead me to my company's JWTcontext file, but I can't really seem to see the wrong url being hardcoded or anything anywhere. But my supervisor told me to look there.

None of the url stuff is my code though so it's kinda confusing for me to look through honestly.

In general also kinda hard to help you help me when I don't know how their server is set up really


6 months ago

let me know when you know


zerkia
TRIAL

6 months ago

Honestly I don't know if I ever will. I can try calling you and screen sharing to try to explain, but honestly their app is huge so it's kinda hard for me to explain since I didn't make this from scratch, but merely added some functionality to it.


6 months ago

I'm sorry but we would not be able to offer that level of support to your class of plan


zerkia
TRIAL

6 months ago

That's alright


6 months ago

  1. update code to call the backend with a url defined in a variable

  2. set that variable in your service variables


zerkia
TRIAL

6 months ago

I managed to get it working thanks to a friend who had some expertise in the codebase.

Turned out to be a multitude of issues:

  1. Build folder was not gitignored so it defaulted to an old build

  2. some env variables were slightly outdated

  3. whitelist had trailing slashes when they shouldn't have had

Passed my exam though, so thank you all for your help, I greatly appreciate it 🙂

I'm marking this as solved, feel free to close it whenever


6 months ago

awesome!


6 months ago

!s


Status changed to Solved brody 6 months ago