Handle over a cypress.io testcase to non-technical Users - node.js

I've written a testcase with cypress.io which is working fine.
I want that a couple of non-technical people can run this test from their local machines.
My assume was:
Install node-js on the local machines
unzip my project and change to this directory
run ./node_modules/.bin/cypress open
Problem is that the users get the error that cypress is not installed. is there any solution that the users don't have to run npm install cypress --save-dev first? in my understanding i deliver the cypress installation right within my project?
Pls see my project structure here:

on your project you should have a package.json file with cypress in it
"devDependencies": {"cypress": "^4.0.0"}
after they install nodejs, they just need to go into the folder and run npm install or npm i for short.
if you ever encounter an issue with the npm command, use npx instead

Related

Running npm build before/after npm install

I'm not familiar with npm so I might be holding the wrong end of the shovel here...
There is a package on npm that I would like to modify and use in my own project. The package is angular-crumbs. I forked the source repo (https://github.com/emilol/angular-crumbs) into my own account (https://github.com/capesean/angular-crumbs) and then run npm install capesean/angular-crumbs -force. However, this produces a node_modules folder in my project that hasn't been built (and whatever else - as I understand it) with the commands in the source repo's package.json file:
"build": "npm run clean && npm run transpile && npm run package && npm run minify && npm run copy"
i.e. it doesn't have the types, the correct package.json file, etc.
So my question is, how do I get the properly-built files (including type definitions, etc.) from my own repo to install or build-after-installing in my target project?
I am not sure about what you're trying to do, are trying to work on the
angular-crumbs source code, or are you trying to use it in your own project as a dependencuy ?
Anyway, running npm install will install all your dependencies so that you can directly use them in your project, those dependencies don't need to be built after they are installed.
In your case you seem to have an angular application (which is completely different from node.js), usually to start an angular app you can run ng serve which will build your source code and run an angular server so you can access it on localhost.

"vite is not recognized ..." on "npm run dev"

I'm using Node.js and npm for the first time, I'm trying to get Vite working, following the tutorials and documentation. But every time I run into the problem 'vite' is not recognized as an internal or external command, operable program or batch file. I have been trying to find a solution for 4 hours now but with no results.
I tried restarting pc, reinstalling node.js, several procedures to create vite project but in vain. I suppose it's my beginner's mistake, but I really don't know what to do anymore.
Commands and responses I run when I try to create a vite project:
npm create vite#latest
>> my-portfolio >> vanilla & vanilla
cd my-portfolio
npm install >>resp: up to date, audited 1 package in 21s found 0 vulnerabilities
npm run dev
resp:
> my-portfolio#0.0.0 dev
> vite
'vite' is not recognized as an internal or external command,
operable program or batch file.
try to install the packages to make it work
npm install or npm i
For this error use the following command on your terminal in the present working directory of the project
npm install
npm run dev
first, try to install a node package manager and then run npm run dev hope it will work
yarn add vite
on project folder to add vite,
and run
npm run dev
again.
remember to update your node version to 18, LTS from 17 might not support this installation.
update:
I try to fresh install again my Laravel 9.19, since i had update my node to version 18, npm install & npm run dev just work fine without yarn.
According to documentation https://vitejs.dev/guide/#community-templates
npm install
npm run dev
npx vite build
I found myself in the same situation.
The problem is vite.cmd is not in the system or user PATH variable, so it cannot be found when it is executed from your project folder.
To fix it, you should temporarily add the folder where vite.cmd is in your PATH variable (either for the entire system or your user). I recommend adding it just for your user, and keep in mind you should probably remove it after you stop working on that project, because this could affect future projects using the same build tools.
To do this:
My PC > Properties > Advanced system settings > Click on Environment Variables (alternatively just use the start button and begin typing Environment, you should get a direct link)
On "User variables" find "Path" and edit it.
Add a new entry for the folder where vite.cmd is. Example "C:\dev\reactplayground\firsttest\test01\node_modules.bin" Check your project folder to find the right path.
Make sure your close and open your console for this change to affect.
Go back to your project root folder and run "vite build", it should work now.
for me I've:
1 - excuted yarn add vite
2- and then npm install
work fine !
For me I had a project I created on one computer and it had this in devDependencies:
"vite": "^3.1.0"
I did pnpm install and it reported everything was fine, but I was getting the error. I ran pnpm install vite and it installed it again with this:
"vite": "^3.1.8"
After that it worked fine. So try using npm, yarn, or pnpm to install the vite package again and see if that works.
try npm install
then npm run build
Recently faced this error and I run
npm install
npm run dev
then the output was
VITE v3.2.4 ready in 1913 ms
THAT'S COOL 😎😎😎
reference LINK
You need Node version 15 or higher, I had the same problem because I was using an older version of it.
Needs to install all the packages in package.json and run again
npm i
npm run dev
For me this worked:
I changed NODE_ENV environment variable to development ( earlier it was production - which should not be the case, as dev-dependencies won't get installed by npm install or yarn )
Here is what to make sure before running npm install or yarn:
Make sure `NODE_ENV` environment variable is not set to `production` if you running locally for dev purpose.
'vite' is not recognized as an internal or external command, operable program or batch file.
> vite
'vite' is not recognized as an internal or external command,
operable program or batch file.
try to install the packages to make it work
npm install or npm i
The following works just fine!
npx vite build
npm i
npm run dev
I had the same challenge and I was finding the error
create-vite : command not found
I resolved by running the command:
npm i create-vite
From there you can continue with running the command:
npm create vite#latest
Reference:
https://www.npmjs.com/package/create-vite
npm install or npm i
helps with issue of 'vite' is not recognized
After I tried npm install
i could run the npm run dev after and it showed me the localhost

why i am not able to install all the dependencies in react?

enter image description hereI tried running all the commands including npx create-react-app npm create-react-app npm install npm clear cache --f everything.
still i am not able to install all the dependencies in my package json
The fact that a package is asking for funding should not affect your installation. It simply means that the author(s) is/are looking for financial support to continue their work.
To create a new installation and avoid possible issues - go to a new directory and type the following on your command prompt:-
npx create-react-app todo1
Then, you need to navigate to the folder of your newly created app, "todo1" by running the following:
cd todo1
Finally to run the app, type the following:
npm start
First I want to say your commands are not clear and those are not separated. I assume you need to create react app with npm package manager.
If you run npx create-react-app todo1 you will create a react app with yarn dependency manager.
If you need to use npm dependency manager use the following command
npx create-react-app todo1 --use-npm
Then check the root directory. it should have the package.json file with necessary initial dependencies.

Why is Heroku telling me it cannot find a package.json in my module when I do a heroku push

I created my own npm package from a fork of react-coverflow. It appears to be working fine in my app locally using it this way: "npm install react-coverflow-mod" --save.
I can run my app using "run with debug (F5)" in VsCode and npm start on the client folder to start the React front end.
Then I do an npm run build on the client folder, and it works just fine.
When I do a heroku push it fails everytime with this error:
npm ERR! code ENOLOCAL
npm ERR! Could not install from "../../react-coverflow-mod"
as it does not contain a package.json file.
1. I know there is a package.json in the module because I can install it via "npm install react-coverflow-mod": https://www.npmjs.com/package/react-coverflow-mod
2. The installed module has a package.json file in it
3. My github repo has a package.json in it: https://github.com/leroyvaughan/react-coverflow
I'm not sure how I can fix this. Do I need a package.json to go into the /Dist folder? What is wrong here with Heroku.
It seams like heroku try to install a package from a relative path instead of the published name. That would perfectly explain why you can run locally but not on a production environment.
Open your project and search for the exact string displayed in your log: "../../react-coverflow-mod" and you should be able to find quickly where it is.
If you run on a unix system (don't know about windows) you can do a search using grep:
grep -rnw '/path/to/somewhere/' -e '../../react-coverflow-mod'
Make sure it includes your root folder which contain package.json, and might we wise to ignore node_modules which is always massive.

How to install a node.js package using npm

I need help trying to install a node.js package from Github using the npm command prompt. It's an adaptive grid Jquery plugin called Masonjs: https://github.com/DrewDahlman/Mason.
It's my first time to use node.js, hence the difficulty understanding the setup instructions. I've CD'd to the project folder and run the 'install npm' and 'install bower' steps successfully, but I don't understand how to complete the remaining steps: running and building Gulp (is building necessary?).
Any help would be very much appreciated.
If you just want to use masonjs library in your project, you don't need to run gulp commands for running and building. Just cd into your project directory where you have initialized npm/bower and run npm install masonjs / bower install masonjs.
The next step would be to add the mason.js file in your index page. Now there would be different folder structure in which this mason.js file is present.
In case of npm module the path would be {your-project-directory}/node_modules/masonjs/lib
And in case of bower components the path would be {your-project-directory}/bower_components/MasonJS/dist
Now just use this library and it will work perfectly.

Resources