Skip to content

Commit ea30015

Browse files
committed
fix(nvm): don't use local npm version when getting the bin
no issue - pass {preferLocal: true} to the `npm bin -g` execa command so that the npm version located by the CLI is the same as the one the user normally uses
1 parent 2a8de70 commit ea30015

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/commands/doctor/checks/install.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const tasks = {
3737
});
3838
},
3939
nodeVersion: function nodeVersion(ctx) {
40-
let globalBin = execa.shellSync('npm bin -g').stdout;
40+
let globalBin = execa.shellSync('npm bin -g', {preferLocal: false}).stdout;
4141

4242
if (process.argv[1] !== path.join(__dirname, '../../../../bin/ghost') && !process.argv[1].startsWith(globalBin)) {
4343
return Promise.reject(new errors.SystemError(

test/unit/commands/doctor/install-spec.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('Unit: Doctor Checks > Install', function () {
5252
expect(error).to.be.an.instanceof(errors.SystemError);
5353
expect(error.message).to.match(/version of Ghost-CLI you are running was not installed with this version of Node./);
5454
expect(execaStub.calledOnce).to.be.true;
55-
expect(execaStub.calledWithExactly('npm bin -g')).to.be.true;
55+
expect(execaStub.calledWithExactly('npm bin -g', {preferLocal: false})).to.be.true;
5656
});
5757
});
5858

0 commit comments

Comments
 (0)