Hey @Kraken
You have to run the command as sudo: sudo npm install -g etc...
Let me know
By checking your console it seems like truffle successfully migrated only one file while they should be two:
Follow these steps:
Restart Ganache;
Choose βnew workspaceβ
Click on βadd projectβ and select the truffle-config.js file inside your project root.
Click on βsave workspaceβ
cd into your project root using your terminal
run truffle migrate
Truffle should migrate your project and you should see that reflected in Ganache.
If that does not work push your project on github and share the repo.
Happy coding,
Dani
/**
*/
// const HDWalletProvider = require(β@truffle/hdwallet-providerβ);
// const infuraKey = βfj4jll3kβ¦β;
//
// const fs = require(βfsβ);
// const mnemonic = fs.readFileSync(".secret").toString().trim();
module.exports = {
/**
develop
or test
. You can ask a truffle command to use a specificnetworks: {
// 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: , // 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.1β, // 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β
// }
}
}
};
Hello,
I got this far in the session but canβt proceed. Per the instructions, I created the function setMessage in Atom and typed let instance = await Helloworld.deployed() in the console. However, the message in the console shows an error. I tried it several times too. How do I fix this? What caused it?
Thank you.
Iβm tried redoing the lesson again. But now, like the first time, my console will only compile the migration file. It will not run the Helloworld file. Does anyone know why this is happening? Do I need to delete files in Atom before attempting to run again. This is very frustrating.
What do you mean βcd into your project root using your terminalβ? I am a novice and do not understand that instruction. Plus, I got everything to work but hit a wall following Filipβs directions for setting up function setMessage(). The console would not allow me to create the instance. I restarted and now the same problem where the command line only migrated the migration file. It cannot see the Helloworld file.
What do I need to do?
Hey @cswan1
You should be able to run truffle migrate --reset
, once the contracts are migrated you can truffle console
and interact with them.
The error you posted is telling you the instance
has already been declared, which means that you have to assign the new contract instance by typing instance = await HelloWorld.deployed()
(so omit the let
command to avoid multiple declarations.
But now, like the first time, my console will only compile the migration file. It will not run the Helloworld file.
Run truffle migrate --reset
.
@gabba @filip
I tried to install as per your instructions above and finally installed without the -g.
Now my Terminal is giving the following comments
Last login: Wed Dec 9 19:08:48 on ttys000
aadyakalra@Aadyas-MacBook-Air ~ % npm install [email protected]
npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
added 27 packages, and audited 27 packages in 16s
4 low severity vulnerabilities
To address all issues, run:
npm audit fix --force
Run npm audit
for details.
aadyakalra@Aadyas-MacBook-Air ~ %
should i run the npm audit fix --force. ??
Please help.
I have been trying for the last 2 hours .
I tried with the npm install -g [email protected] - it didnβt work.
Later i tried with npm install [email protected] - it finally worked (but now i donβt remember the location where this installation took place)
so i finally later installed in the below location ( again)
And Now its showing the below mentioned error :
Sorry, name can only contain URL-friendly characters.
Last login: Wed Dec 9 20:52:22 on ttys000
aadyakalra@Aadyas-MacBook-Air ~ % cd /Users/aadyakalra/Documents/Ethereum\ Smart\ Contract\ advanced/Package
aadyakalra@Aadyas-MacBook-Air Package % npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.
See npm help init
for definitive documentation on these fields
and exactly what they do.
Use npm install <pkg>
afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any time to quit.
package name: (package) npm install [email protected]
Sorry, name can only contain URL-friendly characters.
package name: (package)
Thanks brutherin, that worked!
Last login: Thu Dec 10 12:26:42 on ttys000
aadyakalra@Aadyas-MacBook-Air ~ % cd /Users/aadyakalra/Documents
aadyakalra@Aadyas-MacBook-Air Documents % npm init
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.
See npm help init
for definitive documentation on these fields
and exactly what they do.
Use npm install <pkg>
afterwards to install a package and
save it as a dependency in the package.json file.
Press ^C at any time to quit.
package name: (documents)
version: (1.0.0)
description:
entry point: (jsintro.js)
test command:
git repository:
keywords:
author:
license: (ISC)
About to write to /Users/aadyakalra/Documents/package.json:
{
βnameβ: βdocumentsβ,
βversionβ: β1.0.0β,
βdescriptionβ: ββ,
βmainβ: βjsintro.jsβ,
βscriptsβ: {
βtestβ: βecho βError: no test specifiedβ && exit 1β
},
βauthorβ: ββ,
βlicenseβ: βISCβ
}
Is this OK? (yes)
aadyakalra@Aadyas-MacBook-Air Documents % npm install [email protected]
npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
[email protected] postinstall /Users/aadyakalra/Documents/node_modules/truffle
node ./scripts/postinstall.js
npm audit fix
to fix them, or npm audit
for details[email protected] postinstall /Users/aadyakalra/Documents/node_modules/truffle
node ./scripts/postinstall.js
37 packages are looking for funding
run npm fund
for details
fixed 1 of 1 vulnerability in 27 scanned packages
aadyakalra@Aadyas-MacBook-Air Documents % truffle init
zsh: command not found: truffle
aadyakalra@Aadyas-MacBook-Air Documents % npm fund
[email protected]
βββ¬ https://opencollective.com/mochajs
β βββ [email protected]
βββ¬ https://github.com/sponsors/sindresorhus
β βββ [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
βββ¬ https://github.com/sponsors/isaacs
β βββ [email protected]
βββ¬ https://github.com/sponsors/ljharb
β βββ [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
βββ¬ https://github.com/sponsors/jonschlinkert
β βββ [email protected]
βββ¬ https://github.com/chalk/chalk?sponsor=1
β βββ [email protected]
βββ¬ https://github.com/chalk/ansi-styles?sponsor=1
β βββ [email protected]
βββ¬ https://github.com/sponsors/feross
β βββ [email protected], [email protected]
βββ¬ https://www.patreon.com/feross
β βββ [email protected], [email protected]
βββ¬ https://feross.org/support
βββ [email protected], [email protected]
aadyakalra@Aadyas-MacBook-Air Documents % truffle init
zsh: command not found: truffle
aadyakalra@Aadyas-MacBook-Air Documents % truffle init
zsh: command not found: truffle
aadyakalra@Aadyas-MacBook-Air Documents % npm install [email protected]
npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
[email protected] postinstall /Users/aadyakalra/Documents/node_modules/truffle
node ./scripts/postinstall.js
npm audit fix
to fix them, or npm audit
for details[email protected] postinstall /Users/aadyakalra/Documents/node_modules/truffle
node ./scripts/postinstall.js
37 packages are looking for funding
run npm fund
for details
fixed 1 of 1 vulnerability in 27 scanned packages
aadyakalra@Aadyas-MacBook-Air Documents % npm fund
[email protected]
βββ¬ https://opencollective.com/mochajs
β βββ [email protected]
βββ¬ https://github.com/sponsors/sindresorhus
β βββ [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
βββ¬ https://github.com/sponsors/isaacs
β βββ [email protected]
βββ¬ https://github.com/sponsors/ljharb
β βββ [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]
βββ¬ https://github.com/sponsors/jonschlinkert
β βββ [email protected]
βββ¬ https://github.com/chalk/chalk?sponsor=1
β βββ [email protected]
βββ¬ https://github.com/chalk/ansi-styles?sponsor=1
β βββ [email protected]
βββ¬ https://github.com/sponsors/feross
β βββ [email protected], [email protected]
βββ¬ https://www.patreon.com/feross
β βββ [email protected], [email protected]
βββ¬ https://feross.org/support
βββ [email protected], [email protected]
aadyakalra@Aadyas-MacBook-Air Documents % truffle init
zsh: command not found: truffle
aadyakalra@Aadyas-MacBook-Air Documents % npm install [email protected]
npm ERR! code ETARGET
npm ERR! notarget No matching version found for [email protected].
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesnβt exist.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/aadyakalra/.npm/_logs/2020-12-10T07_34_32_123Z-debug.log
aadyakalra@Aadyas-MacBook-Air Documents % npm install [email protected]
npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
[email protected] postinstall /Users/aadyakalra/Documents/node_modules/truffle
node ./scripts/postinstall.js
[email protected]
added 3 packages from 2 contributors, removed 120 packages, updated 10 packages and audited 27 packages in 10.187s
found 1 low severity vulnerability
run npm audit fix
to fix them, or npm audit
for details
aadyakalra@Aadyas-MacBook-Air Documents % npm audit
=== npm audit security report ===
βββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Low β Prototype Pollution β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Package β minimist β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Dependency of β truffle β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Path β truffle > mocha > mkdirp > minimist β
βββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β More info β https://npmjs.com/advisories/1179 β
βββββββββββββββββ΄βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
found 1 low severity vulnerability in 27 scanned packages
run npm audit fix
to fix 1 of them.
aadyakalra@Aadyas-MacBook-Air Documents % npm install [email protected]
npm WARN deprecated [email protected]: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797)
[email protected] postinstall /Users/aadyakalra/Documents/node_modules/truffle
node ./scripts/postinstall.js
37 packages are looking for funding
run npm fund
for details
found 0 vulnerabilities
t% aadyakalra@Aadyas-MacBook-Air Documents % truffle init
zsh: command not found: truffle
aadyakalra@Aadyas-MacBook-Air Documents % truffle init
I have tried all methods @gabba @Erno @filip @thecil
but its just not workingβ¦ i have searched on google as wellβ¦
nothing seems to be working,
Hey @Su.kal.Crypto
What you see there are warnings generated by npm, nothing to worry about.
Truffle should work as expected
Hey Dan,
as you would have seen in the above message it says:
βt% aadyakalra@Aadyas-MacBook-Air Documents % truffle init
zsh: command not found: truffleβ
Also, as shown by Filip in his first (Installation) video in Smart contract programming 201, he had said that if everything works fine then the system will generate a basic project for me with files and folders.
so, as you are saying, even if it doesnβt work in the way Filip showed, in my Computer, should i just proceed with the courseβs next video , and eventually everything will work fine ??
i am using a Mac
thanks and regards
Suveett Kalra
Dear Danielle,
Also, because when i am running command ls
in the ethereum-course-advanced folder its showing βHelloworldβ and when i am running command βlsβ again in Helloworld,
itβs going blank unlike in Filipβs video on running βlsβ it was showing the following
contracts. test
migrations. truffle- config.js
see below
Last login: Thu Dec 10 15:10:58 on ttys000
aadyakalra@Aadyas-MacBook-Air ~ % cd /Users/aadyakalra/Documents/ethereum-course-advanced
aadyakalra@Aadyas-MacBook-Air ethereum-course-advanced % ls
Helloworld
aadyakalra@Aadyas-MacBook-Air ethereum-course-advanced % cd /Users/aadyakalra/Documents/ethereum-course-advanced/Helloworld
aadyakalra@Aadyas-MacBook-Air Helloworld % ls
aadyakalra@Aadyas-MacBook-Air Helloworld %
so, you are suggesting that i just proceed to the next Video ??
thanks and regards
Suveett kalra
Last login: Thu Dec 10 15:10:58 on ttys000
aadyakalra@Aadyas-MacBook-Air ~ % cd /Users/aadyakalra/Documents/ethereum-course-advanced
aadyakalra@Aadyas-MacBook-Air ethereum-course-advanced % ls
Helloworld
aadyakalra@Aadyas-MacBook-Air ethereum-course-advanced % cd /Users/aadyakalra/Documents/ethereum-course-advanced/Helloworld
aadyakalra@Aadyas-MacBook-Air Helloworld % ls
aadyakalra@Aadyas-MacBook-Air Helloworld %
@dan-i. kindly see above and revert. Thanks and awaiting. I am really looking forward to completing this course soon, and then the Smart contract Risk assessment/ management course.
regards
Suveett kalra
Hey @Su.kal.Crypto
If you get βcommand not found: truffleβ means that Truffle is not installed globally.
Open your terminal and run sudo npm install -g [email protected]
.
Once done navigate into an (empty) project folder and run truffle init
.
Should work fine.
Let me know
Dear @dan-i
Now its showing the below message
Last login: Thu Dec 10 19:51:22 on ttys000
aadyakalra@Aadyas-MacBook-Air ~ % cd /Users/aadyakalra/Documents
aadyakalra@Aadyas-MacBook-Air Documents % sudo npm install -g [email protected].
Password:
npm ERR! code ETARGET
npm ERR! notarget No matching version found for [email protected]β¦
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesnβt exist.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/aadyakalra/.npm/_logs/2020-12-10T14_22_54_253Z-debug.log
aadyakalra@Aadyas-MacBook-Air Documents % sudo npm install -g [email protected]
npm ERR! code MODULE_NOT_FOUND
npm ERR! Cannot find module βis-npmβ
npm ERR! Require stack:
npm ERR! - /usr/local/lib/node_modules/npm/node_modules/update-notifier/index.js
npm ERR! - /usr/local/lib/node_modules/npm/bin/npm-cli.js
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/aadyakalra/.npm/_logs/2020-12-10T14_23_27_411Z-debug.log
aadyakalra@Aadyas-MacBook-Air Documents %
aadyakalra@Aadyas-MacBook-Air Documents %
kindly revert whats to be done next?
thanks and regards
suveett Kalra