npx hardhat doesnt creates a new project - visual-studio-code

I tried creating a new hardhat project. I tried the following commands in terminal.
npm init --yes
npm install --save-dev hardhat
But when I use the following command
npx hardhat
I am getting the following
I think hardhat have changed the contents. Couldnt find anything in the official document.
Can someone suggest how to create a new project using hardhat.
Edit: Contents of the folder

run
$ npx hardhat --verbose
You will get the location of a hardhat config file like this:
$ hardhat:core:config Loading Hardhat config from /home/lyon/hardhat.config.js +0ms
Delete it and run npx hardhat again

That happens when you are trying to create a hardhat project inside a hardhat project. The same happened to me and I realized that in the parent directory I already had hardhat.config.js file. I had to remove that config file.

Related

How do I run an npm script directly in VS code terminal

I am trying to follow this MS tutorial.
So I install the CLI from the VS code terminal: npm install #azure/static-web-apps-cli
Works.
But following the instructions using "swa init" in the terminal I get this response:
swa : The term 'swa' is not recognized.... etc.
Adding the command to package.json as a script will work, but how do I run it directly from the terminal without adding it to package.json?
npx swa init would pull the swa package and execute it as if it was run from within package.json. You can read more about it on npmjs.com/package/npx
Alternatively, you could have the swa package installed globally with npm i -g #azure/static-web-apps-cli

Using Sails.js with yarn

When I run sails new myapp it generates a package.json file and a /node_modules directory. The sails docs say to cd in and run npm install to get up and running.
I've recently started using yarn and would like to use it to manage the additional dependencies I add to my sails app. However, when I run yarn init (what I think creates the yarn.lock file) it looks like it wants to create my package.json again. And it errors on the entry point question, saying Cannot convert object to primitive value.
Should I just stick to vanilla npm? Can Yarn and Sails play nicely in the sandbox together and share the toys?
In fact, $ yarn init (as well as $ npm init) will just initialize your package.json file by asking a few questions.
Here you don't need to regenerate your package.json but just install your node modules and generate a yarn.lock file to lock your modules versions. You can do this by using $ yarn install or just $ yarn.
You can skip $ yarn init as it does the exact same thing as $ npm init. $ yarn install actually creates the yarn.lock file. Unlike npm, yarn actually respects the engines property in a package.json file. If you run into this you can use $ yarn install --ignore-engines.

How to verify facebook jest is installed successfully

I followed the instructions to install Facebook jest on https://facebook.github.io/jest/docs/getting-started.html#content :
npm install --save-dev jest-cli
After the install command I typed jest in the terminal, and press enter but It popped:
bash: jest: command not found.
But when I run the getting started sample by using npm test in the terminal, it worked well.
So, how can I verify that Facebook jest is installed successfully?
Ways to install a package in npm
In node.js you have two ways to install a package: globally or locally.
The sintax is the following:
// globally
npm install -g [package_name]
// locally
npm install --save-dev [package_name]
So, now what it happens is that you run the local one which downloads the package in node_modules under your project folder.
To check you installed jest properly so you can check on your node_modules if there is a jest folder.
How to check if jest is installed
In addition to that npm is creating a shortcut in you local node_modules under the directory .bin son in there you should find a link to jest.
You can test that like that:
cd your_project_folder
./node_modules/.bin/jest
Why npm test works?
The reason why npm test works is because when you run it npm is going to look for the commands globally and locally.

How can I configure sass with ionic.

I am using the default ionic seed application, I have ran the setup
command ionic setup sass.
I run ionic serve, this should be watching for sass changes but it's not.
I tried to run gulp watch but I am getting an error.Error: Cannot find module 'semver'
Try using sudo ionic setup sass
You might not have had sufficient security privileges, thus not allowing sass to be setup properly. Using sudo will allow the user to act as a superuser and let sass setup correctly.
This worked for me.
First you need to run this command ionic setup sass when you run this command create a scss folder in www folder in scss folder here is style.scss file.
and #import this file in scss/ionic.app.scss path.
#import "www/scss/style.scss" in scss/ionic.app.scss path.
Try this I hope this is work for you.
Please delete the 'node_modules' folder in the project directory and re-run
'npm install'. This worked for me .
Make sure you have changed your index.html to include the relevant css files, as the one previously will no longer be used if you want to use the .min.css one generated by sass.
If removing the node_modules and running npm install doesn't work you can try installing gulp then install sass
npm install -g gulp
ionic setup sass
You can use sass via Ruby:
Install Ruby
Install Sass: npm install -g node-sass
On ionic project (v2) type: npm rebuild node-sass
So whenever you touch sass file(s), you can just rebuild the sass: npm rebuild node-sass if not, it's OK, just continue normal ionic serve
Remark: ionic2 requires sass
Using Sass in ionic project
if you are using windows node cli. goto in your project by
c:\projectname
after
c:\projectname>ionic setup sass
done
http://ionicframework.com/docs/cli/sass.html
Try this. It will setup the sass in your ionic project.
ionic setup sass
If gulp is not setup then run this command first
npm install gulp -g

How do I run protractor from source code

I cloned the protractor code from github (https://github.com/angular/protractor)
Is there a way to run the code from the source code? The documentation is always mentions to install protractor with "npm install", but I want to run the latest code.
Is there an easy way to do this ?
npm install in this context is meant to install the local dependencies for protractor.
You need to just run the protractor script in the bin folder.
git clone https://github.com/angular/protractor.git
cd protractor
npm install
cd bin/
./protractor /path/to/e2e/e2e-conf.js