#Not Working Using An `env var` Within a `.npmrc` File

26 messages · Page 1 of 1 (latest)

lucid ferry
#

Hello,

I am trying to setup Hugeicons' new NPM Token verification method and can get the package installed when passing the token directly into the npmrc file! However, I want to pass this though an enviorment variable to be more secure! But when I do, I am unable to install the package as it can't find the token.

# .env (tried .env \ .env.local \ .env.development)

// I've tried the following
NEXT_PUBLIC_NPM_TOKEN=thetoken
NPM_TOKEN=thetoken
NEXT_PUBLIC_NPM_TOKEN="thetoken"
NPM_TOKEN="thetoken"
NEXT_PUBLIC_NPM_TOKEN = "thetoken"
NPM_TOKEN = "thetoken"
# .npmrc

; I've tried the following
//registry.npmjs.org/:_authToken=$NEXT_PUBLIC_NPM_TOKEN
//registry.npmjs.org/:_authToken=$NPM_TOKEN
//registry.npmjs.org/:_authToken=${NEXT_PUBLIC_NPM_TOKEN}
//registry.npmjs.org/:_authToken=${NPM_TOKEN}

am I missing something?! Do I need to do anything within the next.config.js config file?!

Thanks,
Donald Louch

sinful archBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

brave lotus
#

env variables aren'tloaded

#

if running NPM_TOKEN="thetoken" npm i works that's the cause

lucid ferry
#

Do you know how I can fix this?!

brave lotus
lucid ferry
#

So would it be

// .env
NPM_TOKEN="thetoken" npm i
// .npmrc
//registry.npmjs.org/:_authToken=$NPM_TOKEN

If so, then yes I have tried that and still no luck!

brave lotus
#

just try running

#

in the terminal

#

NPM_TOKEN="thetoken" npm i

#

replacing thetoken with your token

lucid ferry
#

I just tried that and it isn't working either!

brave lotus
#

you're supposed to do it like registry.npmjs.org/:_authToken={$NPM_TOKEN}

#

with the parenthesis

#

and then you add the token to your bash/zshrc

#

since it doesn't pick up from .env iirc but i might be wrong

lucid ferry
#

Okay, do you know if I can have that added to vercel for deployment?!

brave lotus
#

I'm not sure

#

try it and see

#

that was the wrong emoji i thought there was one about tryitandsee

lucid ferry
#

Update: did not work with Vercel 😅

lucid ferry