Hey @ImRONMAN
You need to run as admin (sudo).
sudo npm install -g truffle
keep me posted,
Dani
Hi @ajphminer,
I sometimes have the same problem. I fix it by deleting the Ganache configuration folder. On linux this is ~/.config/Ganache, there must be an equivalent on mac or win.
Hi @ImRONMAN,
I had the same problem.
My first impulse was to install truffle as sudo, but it didnāt solve the problem and apparently it is not a secure procedure. You can find some articles by googling ādont use sudo with npmā.
I fixed it by installing npm globally in my home directory, following the directions in Fixing npm permissions. There is also NPM Permissions On Linux Are Broken: Hereās The Fix, and https://danillolima.com/en/npm/how-to-fix-permissions-on-globally-installing-npm-packages-on-linux/.
mkdir $HOME/.npm-global
npm config set prefix $HOME/.npm-global
npm install -g truffle
or
npm install -g [email protected]
$HOME/.npm-global/bin
Hope this helps.
@filip whenever I try to migrate directly from the truffle console using the command āmigrateā, the console throws an error, but then I get out of the console, and then I run ātruffle migrateā and it works ok. Any idea of why is that happening? By the way, I have always ran ganache from an AppImage file (I dont really know how to install it)
ExtendableError: Unknown network āganacheā. See your Truffle configuration file for available networks.
** at Object.validateNetworkConfig (/usr/lib/node_modules/truffle/build/webpack:/packages/environment/environment.js:110:1)**
** at Object.detect (/usr/lib/node_modules/truffle/build/webpack:/packages/environment/environment.js:16:1)**
** at /usr/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:206:1**
@filip I lost you a little in the payable functions video, since I cannot run migrate directly from the console, I have to do it by running the command ātruffle migrateā and it was ok until now. I did exactly the same modifications to the Helloworld.sol and the migrations file, but it didint work for me. I cannot see the 1000000 wei leaving the account. Please a little help
Regarding the migration issue, if it is still not fixed, please post your truffle config file.
For the payable, I need to read you contract.
this is my config file:
module.exports = {
/**
* Networks define how you connect to your ethereum client and let you set the
* defaults web3 uses to send transactions. If you don't specify one truffle
* will spin up a development blockchain for you on port 9545 when you
* run `develop` or `test`. You can ask a truffle command to use a specific
* network from the command line, e.g
*
* $ truffle test --network <network-name>
*/
networks: {
// Useful for testing. The `development` name is special - truffle uses it by default
// if it's defined here and no other network is specified at the command line.
// You should run a client (like ganache-cli, geth or parity) in a separate terminal
// tab if you use this network and you must also set the `host`, `port` and `network_id`
// options below to some value.
//
// development: {
// host: "127.0.0.1", // Localhost (default: none)
// port: 8545, // Standard Ethereum port (default: none)
// network_id: "*", // Any network (default: none)
// },
// Another network with more advanced options...
// advanced: {
// port: 8777, // Custom port
// network_id: 1342, // Custom network
// gas: 8500000, // Gas sent with each transaction (default: ~6700000)
// gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei)
// from: <address>, // Account to send txs from (default: accounts[0])
// websockets: true // Enable EventEmitter interface for web3 (default: false)
// },
// Useful for deploying to a public network.
// NB: It's important to wrap the provider as a function.
// ropsten: {
// provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`),
// network_id: 3, // Ropsten's id
// gas: 5500000, // Ropsten has a lower block limit than mainnet
// confirmations: 2, // # of confs to wait between deployments. (default: 0)
// timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50)
// skipDryRun: true // Skip dry run before migrations? (default: false for public nets )
// },
// Useful for private networks
// private: {
// provider: () => new HDWalletProvider(mnemonic, `https://network.io`),
// network_id: 2111, // This network is yours, in the cloud.
// production: true // Treats this network as if it was a public net. (default: false)
// }
},
// Set default mocha options here, use special reporters etc.
mocha: {
// timeout: 100000
},
// Configure your compilers
compilers: {
solc: {
version: "0.5.12", // Fetch exact version from solc-bin (default: truffle's version)
// docker: true, // Use "0.5.1" you've installed locally with docker (default: false)
// settings: { // See the solidity docs for advice about optimization and evmVersion
// optimizer: {
// enabled: false,
// runs: 200
// },
// evmVersion: "byzantium"
// }
},
},
};
And for the payable, this is my helloworld.sol and my migrations file:
pragma solidity 0.5.12;
contract Helloworld {
string message = "Hello world!";
function getMessage() public view returns (string memory) {
return message;
}
function setMessage(string memory newMessage) public payable{
message = newMessage;
}
}
const Helloworld = artifacts.require("Helloworld");
module.exports = function (deployer, network, accounts) {
deployer.deploy(Helloworld).then(function(instance){
instance.setMessage('hola javier', {value: 1000000, from: accounts[1]}).then();function(){
instance.getMessage().then(function(message){
console.log("current message is:" + message);
});
});
});
};
Hey @javier_ortiz_mir, remember to use the āpreformatted buttonā to enclose properly the code, so it will be easy for us to review it.
You can use the āPreformatted Textā Button to encapsulate any kind of code you want to show.
function formatText(){
let words = āIām a preformatted Text box, Please use me wisely!ā
}
Carlos Z.
I had issues with installing truffle using
Windows linux subsystem ubuntu 18.04lts and manually installed Nodejs.
Following instructions to use nvm
instead to manage nodejs and npm solved my issue:
https://docs.microsoft.com/en-us/windows/wsl/install-win10
Felt like it was worth mentioning.
Hi, thank you for the assit. now i have successfully installed npm install -g [email protected]. But i keep getting command not found(-bash: truffle: command not found) when i input truffle init .
i am using a mac book, does it affect anything?
Hi, Iāve never worked on a mac, so I donāt know. But ācommand not foundā means that the truffle-command is not in your PATH. You would need to check where the truffle command is located, and then add that location to your PATH variable. And then probably reboot to make sure the new PATH is loaded.
Hi all,
i am on Setter functions lecture with @filip. ive noticed that my Helloworld.sol isnt recognising solidity languageā¦ I dont get any colour highlights on my commands.
i have been able to follow along so far but ive got a feeling im going to encounter a problem soon.
Has anyone had this issue before? has Truffle been installed correctly?
Rob.
@thecil great tip!! I didnt know that.
function canYouSeeMyCodeNow() {
}
@dan-i I really need help please!!
Have you added your truffle config to Ganache?
Settings > Add Project?
Also can you please tell me the network id and RCP server shown in ganache?
cheers,
Dani
Thanks for sharing with the community!
Hey @ImRONMAN
Hi, thank you for the assit. now i have successfully installed npm install -g [email protected]. But i keep getting command not found(-bash: truffle: command not found) when i input truffle init .
Can you please open your terminal and type truffle -v
You should see the version as per screenshot above.
Please let me know.
Cheers,
Dani
Hi @Rob_McCourt
You need to install solidity syntax for Atom: https://atom.io/packages/language-solidity
happy coding,
Dani
@dan-i yes I did it ā¦ I dont understand why is this happening
Network ID is 5777
server is HTTP://127.0.0.1:7545
Working like a sexy BastĀ£$d now :). thanks pal