-
-
Notifications
You must be signed in to change notification settings - Fork 197
fix(npm/pacote): allow tns to be able to use npm configuration properly #4905
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This comment was marked as abuse.
This comment was marked as abuse.
@@ -36,6 +38,20 @@ interface ITestCase extends ITestSetup { | |||
expectedArgs: any[]; | |||
} | |||
|
|||
function createPacoteOptions(source: Object): Object { | |||
const options: { [index: string]: any } = {}; | |||
npmconfig.read().forEach((value: any, key: string) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use a hardcoded config obj here instead of reading the real config from the file system and applying the same business logic in the unit tests.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the details. As far as I understand, the problem is caused by libnpmconfig
which is directly used in the Pacote service. In this way, we cannot inject a Stub returning a hardcoded value in the unit tests. If you refactor this part and extract the npmconfig
related logic into a service, you will be able to mock it in the unit tests and avoid slow disk operations there. Also, have you checked this feature with yarn
? Are they using the same config file?
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Hi @NathanaelA, Thanks for reporting and handling this! It looks OK for a patch release as it's really a bug fix, you just have to rebase the PR on our We will run some tests after you rebase the changes on |
This comment was marked as abuse.
This comment was marked as abuse.
Just rebase it on |
Closing this PR in favor of #4992 |
PR Checklist
What is the current behavior?
If you have a npm registry that is not hosted by npm, the TNS cli will fail to install npm modules.
Doing a
npm i --save @proplugins/blah
will work 100% properly.Doing a
tns plugins add @proplugins/blah
will partially work. It actually downloads the package (because it apparently uses npm under the hood and pulls the file and unpacks it, yay!).So
node_modules/@proplugins/blah
is unpacked and exists on the drive.However, apparently the tns cli uses pacote to verify the existence of the registry entry, BEFORE it adds it to the

package.json
file. Which of course because it is a older verison of pacote and does not read the npm configuration -- it has NO idea how to resolve@scoped
to the private server. So tns then fails and so then tns throwsAs you can see from the image; npm actually found the package and installed it; but TNS failed and either rolls back the package.json change, or doesn't commit the package.json change.
What is the new behavior?
Upgraded to latest pacote library; and added ability to read npm configuration files (using the official libnpmconfig, which is then passed into pacote; so of course it now works properly. :-)
BREAKING CHANGES:
None