sybilrondeau Posted May 14, 2021 Share Posted May 14, 2021 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 More sharing options...
Gr0x Posted May 14, 2021 Author Share Posted May 14, 2021 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 More sharing options...
Solution Gr0x Posted May 14, 2021 Author Solution Share Posted May 14, 2021 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. ❤️ 4 1 Link to comment Share on other sites More sharing options...
sybilrondeau Posted May 14, 2021 Share Posted May 14, 2021 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. 1 Link to comment Share on other sites More sharing options...
Prasanna Posted May 14, 2021 Share Posted May 14, 2021 @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. 1 Link to comment Share on other sites More sharing options...
thirsty Posted January 27, 2022 Share Posted January 27, 2022 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 More sharing options...
Prasanna Posted January 27, 2022 Share Posted January 27, 2022 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. 1 Link to comment Share on other sites More sharing options...
thirsty Posted January 27, 2022 Share Posted January 27, 2022 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 More sharing options...
Prasanna Posted January 27, 2022 Share Posted January 27, 2022 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 More sharing options...
thirsty Posted January 27, 2022 Share Posted January 27, 2022 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 More sharing options...
GreenSock Posted January 27, 2022 Share Posted January 27, 2022 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 More sharing options...
BenjaminO Posted August 31, 2022 Share Posted August 31, 2022 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 More sharing options...
Prasanna Posted August 31, 2022 Share Posted August 31, 2022 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 1 Link to comment Share on other sites More sharing options...
BenjaminO Posted September 1, 2022 Share Posted September 1, 2022 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 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now