Truffle init not creating Migration.sol file - solidity

Output for truffle version command:
"Truffle v5.5.27 (core: 5.5.27)
Ganache v7.4.0
Solidity - 0.8.16 (solc-js)
Node v16.16.0
Web3.js v1.7.4"
truffle init does give a success message as below
"Init successful, sweet!
Try our scaffold commands to get started:
$ truffle create contract YourContractName # scaffold a contract
$ truffle create test YourTestName # scaffold a test"
and creates folders and truffle-config.js(refer screenshot) but does NOT create Migration.sol file.
I did try to run the command with sudo but to no avail.
I am using a mac m1.
Please advise.

At last I have got the solution of it. In this case, no need to use truffle init command. You just simply need to go through the command:
truffle unbox
or, you can also set more specific path with the same command:
truffle unbox metacoin [PATH/TO/DIRECTORY]
100% working...

According this thread, Truffle has removed the inclusion of Migration.sol on npx truffle init command since v5.5.27. Now when you run npx truffle init, it includes the following -
an empty contracts folder.\
an empty migrations folder.\
an empty test folder.\
a .gitignore file. \
a truffle-config.js file.\

Related

i tried to add project in hardhat by npx hardhat and it comes out with the error

I was trying to create a project with the npx hardhat and npm error comes out stating could not determine executable to run...
what do you suggest to do-like how can i run npx hardhat command and create my project successfully
maybe you have a typo. Try:
npx hardhat --version

sh: hardhat: command not found when installing Hardhat

Trying to build a project with Hardhat, I have node v15.14.0, and ran the following commands:
npm init -y
npm install --save-dev hardhat
Terminal gives me:
Then I ran:
npx hardhat
But got an error saying:
sh: hardhat: command not found
You should use NPX.
The Node Package eXecute allows us to directly access and execute a package stored (or not) in $ ./node_modules/.bin/your-package.
Using npx hardhat [GLOBAL OPTIONS] <TASK> everything will works fine!
Running npm install --save-dev hardhat again did it for me.

Issues running truffle: command not found

I'm trying to deploy a Smart Contract, before that I need to run truffle compile but I get the error
bash: truffle: command not found
I've installed truffle with npm globally and locally, I tried these commands (worked for someone else in my course)
npm init
npm i truffle
./node_modules/.bin/truffle init
but when I run
npm i truffle
I get "unsupported architecture" amongst tons of other errors. all of these fixes are not working, how can I fix this problem from the root of it?
Also trying sudo:
sudo npm install -g truffle
does install it i guess but also gives the error:
truffle#5.4.14 postinstall /Users/khalidhamid/.npm-
global/lib/node_modules/truffle
> node ./scripts/postinstall.js
Error: EACCES: permission denied, open
'/Users/khalidhamid/Library/Preferences/truffle-
nodejs/config.json'
regardless, it still gives truffle: command not found
Is there any specific reason to install truffle using npm i truffle in your project? I mean, just install it globally and cd into your new directory and use truffle init to craft a new project. This way you can use truffle architecture to write your contracts and also use all available truffle commands. Also using truffle config file you can change the solidity compiler version according to your needs.

Resetting path for Truffle module

I'm trying to follow along with this token tutorial: https://www.youtube.com/watch?v=_ikc4Ct7wvk
When trying to use the truffle module, I cannot use any truffle command "command not found" unless I type in this path:
./node_modules/.bin/truffle"
How can I set this so that I don't need to specify this path to run the commands?
If it's globally installed you can execute truffle command. If it's locally installed you can yarn run truffle if you use Yarn package manager. Another way would be adding a shortcut to bashrc file.
I would recommend using Yarn package manager if you ask my recommendation.

Truffle command not found after installation

I installed truffle through npm with the following:
sudo npm install -g truffle
but when I run truffle list on the console it just gives me
bash: truffle: command not found
I had a similar problem. I ran npm i -g truffle and then when I tried to run truffle init I got an error: zsh: command not found: truffle. What solved it for me is to create a local node_modules with truffle installed in it, and then run that copy.
run npm init and make a new npm project
run npm i truffle
run ./node_modules/.bin/truffle init and it should work!
Please make sure you have the latest version of npm and node installed. I had the same issue, I updated npm and node to latest version and it worked.
npm install -g truffle works.
After installing truffle:
npm install -g truffle
Run on your project folder:
npx truffle init
I did it on a Virtual box and had the same issue, but it worked after I restarted the computer. Hopefully that works for you too
You should add the following to your path system variable.
C:\Users\UserName\AppData\Roaming\npm
(This folder contains the truffle.cmd file)
I have tried and it works.
I tried everything. Followed the instruction on official truffle website and above answers.
Still it didn't seem to worked.
Finally, this worked for me.
Go to C:\Users\Username\AppData\Roaming\npm
There you will find truffle.cmd Double click on it and your done.
npm i truffle does the exact same thing as npm install -g truffle except that installs it globally, and without -g it will be installed on the local folder. Try to update the npm, node, and probably you have a broken node installation from previous versions.
Using npm install -g truffle worked for me instead of npm i truffle
Nothing above worked for me, but I did:
nix truffle unbox react
truffle develop
atom . //opens up the react file project in the atom platform
Try to start with your command like
npx truffle <your command>
You should add C:\Users\UserName\AppData\Roaming\npm (it contains truffle.cmd file) to the path user variables. I have tried and it works
If you have a custom path for your packages, then make sure that you are exporting it when the terminal loads.
For bash:
nano ~/.profile
For zsh:
nano ~./zshrc
And add your custom path, most of the time this will be "npm-global".
export PATH=~/.npm-global/bin:$PATH
These are two simple steps the properly solve this problem for Linux Users:
1- Configure npm to install software globally in your home directory as follows :
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
2- If you are using bash, then execute the following:
echo -n "export PATH=~/.npm-global/bin:$PATH" >> ~/.profile
However, if you are using zsh instead, then execute the following command:
echo -n "export PATH=~/.npm-global/bin:$PATH" >> ~/.zshrc
Note that, if you are using both bash and zsh, it is better to execute the two commands above.