function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
BHASKAR GANGULYBHASKAR GANGULY 

sfdx command not working after npm install --global sfdx-cli

Hi All,
i have node.js installed in my pcversion is v.8.12,0.
i am trying to install salesforce cli by using npm install --global sfdx-cli command.
the install seems to be successful as its extracting all the metadata.However after installation while running the SFDX command its not working.Also i was not able to find any folder created as a result of cli installation.
Can anybody help me here.

Thanks,
Bhaskar
Khan AnasKhan Anas (Salesforce Developers) 

Hi Bhaskar,

Greetings to you!

Please make sure the PATH in the terminal is the same as what you have for VS Code. 

Check your terminal path:
1. Open your terminal
2. Executeecho $PATH. 

Check your VS Code path:
1. In VS Code, Help > Toggle Developer Tools
2. In the console at the bottom of the screen, could you show me the output of typing in process.env.PATH?

Also, try to update your npm. Try this to update node:
npm i -g npm

Then run the CLI install again:
npm install sfdx-cli --global

Please refer to the below links which might help you further with the above issue.

https://www.npmjs.com/package/sfdx-cli

https://salesforce.stackexchange.com/questions/163795/sfdx-is-not-recognized-as-an-internal-or-external-command

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
Ajay K DubediAjay K Dubedi
Hi BHASKAR,

My suspicion is that your PATH in the terminal is different from what you have for VS Code.

Check your terminal path
Open your terminal
Executeecho $PATH. Could you show me the output of that?

Check your VS Code path
In VS Code, Help > Toggle Developer Tools
In the console at the bottom of the screen, could you show me the output of typing in process.env.PATH?

If everything is set up properly, the paths should match and there should be something like the global node_module directory with the npm version of Salesforce CLI installed in the path.

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks,
Ajay Dubedi
BHASKAR GANGULYBHASKAR GANGULY
Hi Khan and Ajay,
First of all thanks for your inputs.
When i did execute path in cmd i am getting below path.
PATH=C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (
x86)\PVCS\vm\win32\bin\;C:\Program Files (x86)\PVCS\vm\common\bin\win32\;C:\HIG\
UTIL;C:\Oracle\product\11.2.0\client\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDO
WS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32
\WindowsPowerShell\v1.0\;C:\Program Files (x86)\WinZip\;C:\Program Files (x86)\C
heckPoint\Endpoint Security\Endpoint Common\bin;C:\Program Files (x86)\HID Globa
l\ActivClient\;C:\Program Files\HID Global\ActivClient\;C:\WINDOWS\System32\Wind
owsPowerShell\v1.0\;C:\Program Files\Adobe\Adobe PDF iFilter 11 for 64-bit platf
orms\bin\;C:\Program Files (x86)\Java\jdk1.8.0_201\bin;C:\Program Files\nodejs\;
C:\groovy-2.5.6\bin;C:\Program Files\Java\jdk1.8.0_201\bin;C:\Users\COG12537\App
Data\Local\Programs\Microsoft VS Code\bin;C:\Users\COG12537\AppData\Local\Progra
ms\Git\cmd;C:\Users\COG12537\Desktop\cli\Microsoft VS Code\bin

also as per your suggesion when i checked by Toggle developer tools i get the below path.

"C:\Program Files (x86)\Google\Chrome\Application;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\PVCS\vm\win32\bin\;C:\Program Files (x86)\PVCS\vm\common\bin\win32\;C:\HIG\UTIL;C:\Oracle\product\11.2.0\client\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\WinZip\;C:\Program Files (x86)\CheckPoint\Endpoint Security\Endpoint Common\bin;C:\Program Files (x86)\HID Global\ActivClient\;C:\Program Files\HID Global\ActivClient\;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Adobe\Adobe PDF iFilter 11 for 64-bit platforms\bin\;C:\Program Files (x86)\Java\jdk1.8.0_201\bin;C:\Program Files\nodejs\;C:\groovy-2.5.6\bin;C:\Program Files\Java\jdk1.8.0_201\bin;C:\Users\COG12537\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\COG12537\AppData\Local\Programs\Git\cmd;C:\Users\COG12537\Desktop\cli\Microsoft VS Code\bin"

which path i need to execute the NPM.

Please help.

Thanks,
Bhaskar
SForceBeWithYouSForceBeWithYou
I ran into this problem after installing sfdx through npm in a GitHub Action yml file.  The way I resolved this is to use
node_modules/sfdx-cli/bin/run

instead of just call sfdx, so an example command
node_modules/sfdx-cli/bin/run force:source:deploy -c -w 20 -x manifest/package.xml -l RunLocalTests

Hope that helps someone!