Jump to content
GreenSock

Gr0x

Netlify deploy error with greensock-member

Go to solution Solved by Gr0x,

Recommended Posts

Hi ! I put this line :

registry=https://npm.greensock.com

in the .npmrc file and it worked ! But Cassie said it could fail because of the other packages... so I deleted it and now each time I push on Github it's still working. 

Have you tried it ? 

Link to comment
Share on other sites

So you went from:

--------------------------

always-auth=true
@gsap:registry=https://npm.greensock.com/
//npm.greensock.com/:_authToken=${NPM_TOKEN}

--------------------------

to:

--------------------------

always-auth=true
registry=https://npm.greensock.com
//npm.greensock.com/:_authToken=${NPM_TOKEN}

--------------------------

 

Am I correct? No I haven't tried it yet, gonna do it asap 😃

 

Link to comment
Share on other sites

  • Solution

Solution: 

1: Create .npmrc file in root of your project.

2: write following in the .npmrc file:

--------------------------

always-auth=true
registry=https://npm.greensock.com
//npm.greensock.com/:_authToken=${NPM_TOKEN}

--------------------------

3: Go to Netlify and create an enviroment variable called :         NPM_TOKEN

4: Push it up to your git repo and enjoy

 

Shout out to Cassie, Prasanna and Sybilrondeau. ❤️

  • Like 4
  • Thanks 1
Link to comment
Share on other sites

I did nothing, @Cassie did ! But be aware, as she said, it can also break the installation as it will be ok for gsap but not the other packages, so it's not so much a good solution for everybody.

  • Like 1
Link to comment
Share on other sites

@Gr0x - looking at the .npmrc file content that you provided, it should throw errors in while running $npm install your local environment (unless you specify env vars). But it should be working fine in netlify.

  • Like 1
Link to comment
Share on other sites

  • 8 months later...

I can confirm that actually just making your .npmrc file 
 

always-auth=true
registry=https://npm.greensock.com
//npm.greensock.com/:_authToken=FAKE-FAKE-FAKE-FAKE

 

And committing it, works too, without needing to set NPM_TOKEN environment variable

Link to comment
Share on other sites

1 hour ago, thirsty said:

I can confirm that actually just making your .npmrc file 
 

always-auth=true
registry=https://npm.greensock.com
//npm.greensock.com/:_authToken=FAKE-FAKE-FAKE-FAKE

 

And committing it, works too, without needing to set NPM_TOKEN environment variable

 

Yes it does, but as a practice it is recommended no to commit tokens/keys in your project.

  • Like 1
Link to comment
Share on other sites

2 minutes ago, Prasanna said:

 

Yes it does, but as a practice it is recommended no to commit tokens/keys in your project.

Just removes the hassle of setting env var NPM_TOKEN for every yarn command 😮

Any idea why setting global registry to npm.greensock.com works lol? You think there's some kind of fallback system that yarn and npm use if the registry endpoint doesn't return a package?

As in, there's no issue installing any other packages even though registry is set globally to greensock domain?

Link to comment
Share on other sites

7 minutes ago, thirsty said:

Any idea why setting global registry to npm.greensock.com works lol? You think there's some kind of fallback system that yarn and npm use if the registry endpoint doesn't return a package?

As in, there's no issue installing any other packages even though registry is set globally to greensock domain?

 

The registry service used by npm.greensock.com uses the official npm registry as fallback registry. Hence you would still be able to install all packages when you set npm.greensock.com as the global registry. There is no problem with configuring npm.greensock.com as the global registry but package installation could be slower in some cases (in cases when the package requested is not readily available in the npm.greensock.com registry)

 

As for the fallback registry, it is currently not possible to set two global registries. But you can set a registry for scoped packages and use global registry as a fallback.

Link to comment
Share on other sites

6 minutes ago, Prasanna said:

 

The registry service used by npm.greensock.com uses the official npm registry as fallback registry. Hence you would still be able to install all packages when you set npm.greensock.com as the global registry. There is no problem with configuring npm.greensock.com as the global registry but package installation could be slower in some cases (in cases when the package requested is not readily available in the npm.greensock.com registry)

 

As for the fallback registry, it is currently not possible to set two global registries. But you can set a registry for scoped packages and use global registry as a fallback.


Ah ok, interesting, probably not the best to rely on greensock for all of our dependancies.

It's weird that @gsap:registry='...' doesn't work to single out the gsap repository? Even though it works locally, I'll check what yarn version netlify uses

Link to comment
Share on other sites

1 hour ago, thirsty said:

Ah ok, interesting, probably not the best to rely on greensock for all of our dependancies.

Yes, please don't do that :)

Link to comment
Share on other sites

  • 7 months later...
On 5/14/2021 at 4:06 PM, Prasanna said:

@Gr0x - looking at the .npmrc file content that you provided, it should throw errors in while running $npm install your local environment (unless you specify env vars). But it should be working fine in netlify.

Hello 👋, do you know how to specify env vars in local environment ? I am having a 403 error locally

my config

// .env file at the root of the project
NPM_GREENSOCK_TOKEN=my_super_token
// .npmrc at the root of the project
//npm.greensock.com/:_authToken=${NPM_GREENSOCK_TOKEN} -- Note : putting directly the token here is working fine
@gsap:registry=https://npm.greensock.com
when I am running "npm i gsap@npm:@gsap/shockingly"

npm ERR! code E403
npm ERR! 403 403 Forbidden - GET https://npm.greensock.com/@gsap%2fshockingly - bad authorization header. Please login again
npm ERR! 403 In most cases, you or one of your dependencies are requesting
npm ERR! 403 a package version that is forbidden by your security policy, or
npm ERR! 403 on a server you do not have access to.

 

Link to comment
Share on other sites

6 hours ago, BenjaminO said:

Hello 👋, do you know how to specify env vars in local environment ? I am having a 403 error locally

my config

Hi,

In windows you can set the env variables in a pretty straightforward manner - using the Environment variables dialog. Reference: https://docs.oracle.com/en/database/oracle/machine-learning/oml4r/1.5.1/oread/creating-and-modifying-environment-variables-on-windows.html#GUID-DD6F9982-60D5-48F6-8270-A27EC53807D0

 

On a macbook, you can run the following command to set the env variable:

$ echo "export NPM_GREENSOCK_TOKEN=xxxx-xxxx" | sudo tee -a ~/.zshrc

 

Let me know if this helps

 

Prasanna

  • Like 1
Link to comment
Share on other sites

17 hours ago, Prasanna said:

Hi,

In windows you can set the env variables in a pretty straightforward manner - using the Environment variables dialog. Reference: https://docs.oracle.com/en/database/oracle/machine-learning/oml4r/1.5.1/oread/creating-and-modifying-environment-variables-on-windows.html#GUID-DD6F9982-60D5-48F6-8270-A27EC53807D0

 

On a macbook, you can run the following command to set the env variable:

$ echo "export NPM_GREENSOCK_TOKEN=xxxx-xxxx" | sudo tee -a ~/.zshrc

 

Let me know if this helps

 

Prasanna

Hey @Prasanna! Thank you for your response. I opted for another method using dotenv-cli https://www.npmjs.com/package/dotenv-cli. to update or install packages I just have to put the dotenv parameter before using npm :

dotenv npm install
dotenv npm install gsap@npm:@gsap/shockingly
dotenv npm install gsap

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×