Truffle Command Not Recognized – Fixed
by Alexandra Kropova from Mammoth Interactive
Trying to Use the Truffle Command?
- Are you trying to start a new Truffle project with the Terminal command ‘truffle init‘?
- Maybe you’re trying to use truffle for something else.
- Getting the error message ‘truffle is not recognized as an internal or external command, operable program or batch file.’?
Want to learn more? Enroll in Beginners Solidity for Ethereum Blockchain Masterclass - Build Smart Contracts. Free in the Mammoth Unlimited Membership. Get 200+ courses and 2,000 hours at a dirt-cheap price.
Your solution:
Use the command
npx truffle init
Notes for this to work
You must have done the following beforehand:
- Created a new project folder with mkdir projectFolderName
- Initialized a package.json file with the command npm init
- Installed truffle locally with the command npm install truffle –save-dev
What is npx?
- stands for Node Package Execute
- comes with the npm above 5.2.0 version
- an npm package runner that can execute any package that you want from the npm registry without even installing that package.
When executing a package, it will look for the package binaries either from the local or global installation
‘truffle’ still not working?
Close and restart your Terminal. You often have to do this after installing a package globally.
Suggest more solutions or ask a question in the comments below.
Want to learn more? Enroll in Beginners Solidity for Ethereum Blockchain Masterclass - Build Smart Contracts. Free in the Mammoth Unlimited Membership. Get 200+ courses and 2,000 hours at a dirt-cheap price.