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

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

Related

Truffle init not creating Migration.sol file

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.\

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.

using the npx command to run a react-native project

Previously, when I had tried using react-native we were told to use react-native run-ios to run the project from the command line. Now, the instructions say to use npx react-native run-ios from the command line.
What in the benefit of using npx. Does using npx change how the project is compiled? If I sometimes use npx and sometimes neglect to use it will it mess anything up in my project?
Check this answer more about of npx
react-native supported and recommended to use npx start from react-native#0.60.0.
The benefit of using npx is don't need to install react-native-cli tools globally. Check the below example of using npx and not for the react-native project.
### Using npx ###
﹩ npx react-native init <SimpleProjectName>
### Without using npx ###
﹩ npm i -g react-native-cli
﹩ react-native init <SimpleProjectName>
Both react-native-cli and npx react-native are should not use in one project. The official docs said before starting a new project:
If you previously installed a global react-native-cli package, please remove it as it may cause unexpected issues.

How to fix error in "Copying template" when making project?

I'm generating a new project using React-Native in Command Prompt but I get an error when I use the following command:
react-native init Style
This is the result I get:
√ Downloading template
× Copying template
error Error: Cannot find module 'C:\Users\User\AppData\Local\Temp\rncli-init-template-srEvW0\node_modules\react-native\template.config'
error EBUSY: resource busy or locked, rmdir 'D:\FUSI\React Native\Style'. Run CLI with --verbose flag for more details.
Error: EBUSY: resource busy or locked, rmdir 'D:\FUSI\React Native\Style'
at Object.rmdirSync (fs.js:684:3)
at rmdirSync (D:\FUSI\React Native\node_modules\fs-extra\lib\remove\rimraf.js:276:13)
at Object.rimrafSync [as removeSync] (D:\FUSI\React Native\node_modules\fs-extra\lib\remove\rimraf.js:252:7)
at Object.initialize [as func] (D:\FUSI\React Native\node_modules\react-native\node_modules#react-native-community\cli\build\commands\init\init.js:295:26)
at process._tickCallback (internal/process/next_tick.js:68:7)
How can I fix this error?
Mustafa AK had it right. What worked for me is adding the --npm flag at the end of the command.
I followed the tutorial exactly how it was laid out on the React website and was running into the same error. For whatever reason, if you have yarn and npm installed the command to create a new project will not work. So you have to add the --npm flag to get it to only use npm and this will work.
npx react-native init AwesomeProject --npm
This Same error comes with me. But I solved by following ways...
First, uninstall the node from your system and download the latest version of node and install it.
2.after installation of the latest version of node you need to write the command in your command prompt
npm install -g react-native-cli
Now go to your project directory
cd your-react-native-project directory
now create your react-native project
react-native init your-project-name.
https://stackoverflow.com/a/71725307/16114216
Be sure uninstall global react-native/cli as described react-native tutorials
Try to use --npm end of init command if you had yarn and npm both.
npx react-native init MyApp --template react-native-template-typescript --npm
Note: If you have both yarn and npm installed on your machine, React Native CLI will always try to use yarn, so even if you use npx utility, only react-native executable will be installed using npm and the rest of the work will be delegated to yarn. You can force usage of npm adding --npm flag to the command.

can not install react-native-community/react-native-netinfo

I want to remove "Warning: NetInfo has been extracted from react-native core
and will be removed in a future release.
It can now be installed and imported from '#react-native-community/netinfo'
instead of 'react-native'.
See https://github.com/react-native-community/react-native-netinfo" But when i run command it doesn't work.
npm install --save #react-native-community/netinfo
Because of the # in the name of the package powershell treats it as a variable.
You could fix this by either using cmd.exe or putting the package name in quotes like this: npm install --save "#react-native-community/netinfo"
Actual, #Rik's Answer is correct. i would like to add more..
npm install --save "#react-native-community/netinfo"
run this Command with quotations.
cd android go to your android Project directory
gradlew clean run this to clean your android project
then run either react-native run-android or npx react-native run-android or whatever command you use to start project.