How to run locally installed npm package with npx - npm

I have the following folder structure with the locally installed Cypress module:
cypress-test-project
node_modules
cypress
tests.spec.js
As I read it in this article, npx helps to execute globally and locally installed packages:
Run a locally installed package easily
If you wish to execute a locally installed package, all you need to do
is type:
$ npx your-package
npx will check whether or
exists in $PATH, or in the local project binaries, and if
so it will execute it.
As I have Cypress installed in the node_modules folder, I tried to run the following command:
npx cypress open
This is what I get:
No version of Cypress is installed in:
C:\Users\main\AppData\Local\Cypress\Cache\9.5.1\Cypress
Please reinstall Cypress by running: cypress install
Cypress executable not found at:
C:\Users\main\AppData\Local\Cypress\Cache\9.5.1\Cypress\Cypress.exe
Platform: win32-x64 (10.0.22000) Cypress Version: 9.5.1
Why does npx stop after checking the PATH variable and not looking in the local folder?

Cypress always installs to that user-specific (global) location even if you install locally in the project.
It sounds like the install crashed part way.
Try removing and repeating.

Related

Cypress cannot run because this binary file does not have executable permissions

I was trying to create a new project in cypress and I got the following strange error message.
Steps:
npm init -y
npm install cypress --save-dev
I then did npx open cypress and I got the following message from my console
How do I fix this?
Cypress cannot run because this binary file does not have executable permissions here:
/Users/myName/Library/Caches/Cypress/7.5.0/Cypress.app/Contents/MacOS/Cypress
Reasons this may happen:
- node was installed as 'root' or with 'sudo'
- the cypress npm package as 'root' or with 'sudo'
Please check that you have the appropriate user permissions.
You can also try clearing the cache with 'cypress cache clear' and reinstalling.
----------
Platform: darwin (20.5.0)
Cypress Version: 7.5.0
You can do two things:
Run the command npm cypress cache clear and then again install cypress npm install cypress --save-dev and check.
Or, install npm globally without sudo using the command npm install -g. Then create a new folder and then run npm init, npm install cypress --save-dev and npx cypress open.
Do navigate to the cache directory by doing
cd /Users/myName/Library/Caches/
Here you have to delete Cypress directory completely by running the command
rm -rf Cypress
Now head over to your project directory and run the command
npx install cypress
Cypress will be installed in your system again. Next time you won't get any errors.
So, I had a chat with the dev team at Cypress and got the following answer. After reading the logs I had a feeling this might be the root cause. So please check you have the most up to date version of Node.js

Error: "detox-cli" package is not meant to be installed locally, exiting

I am trying to follow this link to use detox for e2e testing for my react native app. I did it successfully once, but I removed e2e folder, was conducting some experiments, now I am not able to run detox init -r jest
every time I run this line it gives me this error:
Error: "detox-cli" package is not meant to be installed locally, exiting...
HINT: Remove the local installation and reinstall it globally:
npm uninstall detox-cli
npm install -g detox-cli
I have tried the solution in the hint, but it didn't resolve the issue, any suggestions?
If I uninstall and run the command, same error shows up.
when I install it, this is what I see (node version and detox-cli version)
/Users/.../.nvm/versions/node/v14.17.0/bin/detox -> /Users/.../.nvm/versions/node/v14.17.0/lib/node_modules/detox-cli/cli.js
+ detox-cli#18.13.0
updated 1 package in 1.358s
-----Update:
I just tried this and worked:
/Users/.../.nvm/versions/node/v14.17.0/bin/detox init -r jest

Run expo-cli commands locally (using the local expo-cli)

I have expo-cli installed globally in node_modules. I created a React Native Project in which I also installed expo-cli locally (because its in the package.json dependencies of the project).
I noticed that whenever I run an expo-cli command in my project, the global expo-cli is the one always called. I know this because, I updated the local expo-cli to a newer version, and when I try to run a command that exists in the newer version and not the former, its says that the command is not recognized. Or when I run expo-cli -V it shows the version of the global expo-cli, not the newer version installed locally.
My question
How to force expo-cli commands to run with the locally installed version?
Add an npm script in your project's package.json for the expo command
"expo": "expo"
and use npm run expo ... to run you expo commands
In you project you can run npm bin / yarn bin to find the location of the locally installed binary files and invoke that directly.
./node_modules/.bin/expo ...

How to install appium thru npm at offline machine

I have installed nodejs with npm, appium guhub package.
My machine does not has Internet connection
How do I use npm to install the appium?
Npm install -g appium
Is not working.
Try with this steps
Create package.json file using npm-init command
list all the modules in package.json that you need
Run npm-install on your terminal
full reference : https://docs.npmjs.com/cli/v7/configuring-npm/package-json

Babel Errors in Cloud 9 IDE

Getting a bunch of babel errors when running npm run dev with the Vue cli.
This only happens in Cloud9.
Any thoughts on what could be the issue or how to disable errors like this before running npm run dev?
All babel related it looks like.
I couldn't re-create the babel error messages but it's possible that it could be caused if npm/node is not up-to-date. (Vue-cli wasn't starting dev server before the installation below)
Is your repository public where you're getting the error messages? Then I could have a look at the errors.
If removing node_modules folder is not helping,
here is how you can create a new IDE workspace for vue.js ($ for commands in bash terminal):
Create a blank Ubuntu workspace
Check that nvm is installed & up-to-date with (check version of install script here):
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.32.1/install.sh | bash
$ nvm install node 6
$ npm i vue-cli -g
$ vue init webpack yourAppName
$ cd yourAppName
$ npm install
$ npm run dev
Click preview to test that Vue server is running as expected
Here is a link to a HelloWorld Vue app in cloud9 ide.
If you have an existing app you can also use git to clone it into your new workspace instead of creating a new app.