I can't run ganache in my terminal, even though it's installed - npm

It seems I have a path error, I can see proof the package installed, and I've tried it both globally and local, tried both with and w/o the -cli suffix, but zshell keeps complaining command not found
dr_frankenmiller#Bryans-MacBook-Pro ~ % npm install ganache-cli
npm WARN deprecated ganache-cli#6.12.2: ganache-cli is now ganache; visit https://trfl.io/g7 for details
added 1 package, and audited 102 packages in 11s
2 packages are looking for funding
run npm fund for details
9 vulnerabilities (8 moderate, 1 high)
To address issues that do not require attention, run:
npm audit fix
To address all issues (including breaking changes), run:
npm audit fix --force
Run npm audit for details.
dr_frankenmiller#Bryans-MacBook-Pro ~ % npm ls --depth=0
dr_frankenmiller# /Users/dr_frankenmiller
└── ganache-cli#6.12.2
dr_frankenmiller#Bryans-MacBook-Pro ~ % ganache-cli
zsh: command not found: ganache-cli
I might have done something bad, using a sudo rm -rf node_modules command to uninstall the package, was that dangerous to do? I reinstalled it globally and then tried running it again, and then zshell started complaining I wasn't authorized to run ganache. I tried the command sudo ganache, it asked me for password, and then responded again that command not found.
Can someone help me get back on track with my tutorial?

According to Ganache-CLI's instructions, it should be installed with:
npm install ganache-cli -g
I'd recommend installing the latest Ganache version rather than installing Ganache-CLI, though. Ganache-CLI is deprecated. Use
npm uninstall ganache-cli && npm install ganache -g
Ganache v7.0.0 and onward can be used in the CLI as well as programatically.
On another note, I strongly recommend against using sudo when installing anything via npm. This can give untrusted code the ability to run as admin on your system. Definitely a big security risk.

Just a follow up on difficulties I was having, I ended up using yarn to download and run ganache (MINUS the -cli suffix, -cli suffix now deprecated), yarn install ganache --global to install and then yarn ganache to run (no -cli necessary)

Here's how I found the solution for my specific use case. The bug came about when I was attempting to run a brownie deployment script. Run npm uninstall ganache-cli then run yarn global add ganache. Worked like a charm.

Related

What npm install -s mean?

I am installing some packages on NPM, sometimes I have to write -s and -g? What do they mean?
npm install -s socket.io
npm install -g xxxxxxx
npm -g <package> will install a package globally on your machine. Without the -g or --global flag, the package will be installed locally in the directory you were in when you ran the command.
npm -S <package> with an uppercase -S or --save will install the package and save it to your dependencies in your package.json, although I believe that is now the default behavior in current npm. I recommend reading the docs if you're unfamiliar with what's happening when you pass different options to npm.
#gmmetheny answered the question about the global -g flag, but -s appears to silence the output of the command (at least in npm v7.0.15).
In other words, including -s (or --silent) in your npm install command means that it will have no output (only a newline):
> npm install -s example-package1 example-package2
This may be useful for running the command in a script.
Running the command without the -s flag echoes information about what was installed, e.g.:
> npm install example-package1 example-package2
npm WARN deprecated some-pkg#1.2.3: this library is no longer supported
added 160 packages, and audited 160 packages in 6s
14 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
You can diff the resulting directories created after running each variant of the command and you can verify that the effects are the same.
As #Max mentioned, this option is NOT mentioned in the npm docs (at least not in any prevalent location where a user might find it after a reasonable amount of searching).

Can't run "npm install expo-cli --global"

I am a newbie in all this stuff. Hope for your understanding.
Let me clarify the issue:
I am trying to start react native app through expo cli. So tried to start npm install expo-cli --global to install npm globally. I got these errors:
Screen_1
Screen_2
It also says that I lack permissions to access it. How can I allow permissions?
Even when I try to start it locally I got the same issue. Your help is appreciated.
although this solution is not the best and the safest solution exists, this worked for me and that make sense because all the problem we had with the errors is the permission problems. so you can use this command and ignore those permission problems :
sudo npm install expo-cli -g --unsafe-perm
I was having the same problem with npm install -g expo-cli, having "MODULE_NOT_FOUND",
I installed yarm with brew, just in case you do not already have it:
brew install yarn
and then use:
yarn global add expo-cli
to create a project you can:
expo init nameOfTheNewProject
and choose a template in the console.
Finally run the project with
yarn start
Let me know if it works for you!
You did not mention which os. This answer working for any operating system (ubuntu in my case)
I'm also getting permission errors when running
sudo npm install --global expo-cli
Which I don't really how this can happen - as this also happens for the superuser!
For me it works when I install the client locally into the project
cd <new-project-dir>
npm init # init npm project
npm install expo-cli
Now you can use the client in this project like this:
npx expo-cli # e.g. npx expo-cli init <project-name>
npm cache clean --force
This will solve the issue
Try using npm install -g expo-cli#3.5.0 this worked for me, it may work for you.
You can try this command:
npm install -g expo-cli
or,
yarn global add expo-cli
You have to run the command as administrator from a command prompt on windows and not bash. Had me stumpt for bloody ages!
You need administrator privilege. So when you open command line interface, just right click and run as administrator
This will solve the problem
I guess, this issue comes from permission or node version , if you get this error when the node module is being refreshed ---> This is definitely a permission issue. Disable your Antiviruses or change permission manually check this as well.
First run npm cache verify, then run sudo npm install --global expo-cli.
Did work for me indeed after trying so much.
Follow the steps
First, run npm cache verify.
Open Windows PowerShell as administrator and run npm install expo-cli
--global --no-optional command.
npm cache clean --force then npm install --unsafe-perm -g expo-cli
It is likely you do not have the permissions to access this file as the current user.
The best way to solve this problem is to reinstall npm with a node version manager.And you don't need to remove your current version.
About node version manager
use nvm or n with OSX or Linux
use nodist or nvm-windows with windows
Upgrade Node version to +10
Then do
sudo npm install expo-cli -g
This worked for me. I hope this would solve your problem!
sudo npm install expo-cli -g --unsafe-perm=true --allow-root
If any of the solutions above result in success, please follow the steps below:
Uninstall Node.js
Restart your pc/mac
Download latest version of the Node.js (https://nodejs.org/en/)
Open cmd as admin mode or use "sudo" before the command line on Mac.
npm install expo-cli --global
I hope it can help
In my case, I deleted two files then everything worked. The two files are in this path: C:\Users\{Username}\AppData\Roaming\npm under the names 'expo.ps1' and 'expo-cli.ps1'
Then run:
npm i -g expo-cli
re-install node.js, it works for me
First update Node.js to the latest stable version and then again try to install expo ad clean before expo folders that are being created in below location
C:\Users\{{computer_username}}\AppData\Roaming\npm
If it's throwing error in visual studio code, try from cmd, was facing same error but solved through this way
npm install -g expo-cli
try going into windows resource monitor and terminating adb.exe (android resource bridge). This worked for me after searching for solutions for days. I tried this after verifying cache, clearing cache, you name it.
As a Debian 10 buster user I got the same permission error while using this command: sudo npm install expo-cli --global.
The problem was solved by installing expo-cli with yarn package manager and the command below: sudo yarn global add expo-cli.
For Windows User :-
Open your Powershell and type:
npm install expo-cli --global
This worked for me after trying and reasearching for hours.
Note:Don't Use cmd or any other terminal and also don't type npm install expo-cli -g as it is written in the react native docs. It would always show up an npm error.
For windows
Follow these steps carefully
open the command prompt and run it as administrator.
recommended npm uninstall --global expo-cli.
run the command npm cache clean --force.
run the command npm cache verify .
now run the command npm install --global expo-cli
dont run command like npm i -g expo-cli or npm install -g expo-cli.
7.Make sure you run the command mentioned in the 4th step ONLY.
thankyou.
I had this problem in Windows 10, to be able to install the latest version (I had no choice since it broke the current one). I had to install the latest version of Python (3.8.0) and then run npm install --global --production windows-build-tools as an administrator, then I was able to run again: npm install expo-cli --global to install the version 3.8.0 of the expo-cli
Here is the solution and 100% working. I am working with Windows and not sure abut Linux.
Open cmd and
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
then press yes
Now run the command to start your project
npm install -g expo-cli
I had previously removed Expo from my Windows machine and encountered this error whilst trying to reinstall. Reading the error message solved the problem.
npm i expo-cli -g --legacy-peer-deps
Using this command in 'PowerShell' installed expo successfully.
If anyone else has this problem here is my fix, go to Finder, in the input field (search box) type in /usr/local/lib then press CMD + SHIFT + G press the OK button or whatever pops up, then CMD + SHIFT + . and delete the NVM file i deleted the expo folder too. Then go to this link https://changelog.com/posts/install-node-js-with-homebrew-on-os-x
follow the instructions and install brew, node, etc. Last step go to your terminal and type sudo npm install expo-cli --global
First: I upgraded my mac version 10.13 to 10.15
Then I downloaded homebrew, Watchman, Git and Node.js
Finally I ran this command sudo npm install --global expo-cli --legacy-peer-deps
If you have any further questions check the docs out: https://docs.expo.dev/get-started/installation/
Sometime, I use npm not work.
I try a lots times run with npm but fail for expo cli.
Please try yarn global add expo-cli
It wills save your time ^^.
I was trying to install expo-cli with my company npm registry configured.
I've created 2 differents profiles using npmrc and using the profile with https://registry.npmjs.org/ solved the issue.

VS Code terminal fails to use npm version from nvm

I'm using nvm on my Terminal and successfully installed node 10.2.1, which also installed npm 6.1.0. However, when I go to my VS Code editor, it gives me warnings in the integrated terminal for:
npm WARN npm npm does not support Node.js v10.2.1
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4,6, 7, 8, 9.
Turns out, it is actually using npm 5.5.1 (npm -v).
I check to see what's up with that and tried to dig further and eventually used: which npm on both integrated terminal and Mac's CLI.
Mac's Terminal shows:
/Users/Aiz/.nvm/versions/node/v10.2.1/bin/npm
VS Code's Terminal shows:
/usr/local/bin/npm. Which is interesting, because if you do which node in this terminal, it results in the appropriate /Users/Aiz/.nvm/versions/node/v10.2.1/bin/node.
I'm not sure how to get my VS Code terminal to point to the appropriate npm install through nvm. Not sure if it helps, but I checked npm get prefix and npm -g bin to find /Users/Aiz/.nvm/versions/node/v10.2.1. The only difference I'm finding is where each terminal is using npm from.
I ended up looking through VS Code issues on GitHub and came across something relevant to NVM and node issues. It fixed my issue since the underlying cause was the same.
Essentially what happened is that I had a global install of node before that I removed prior to using NVM but hadn't removed my global install of npm. This was causing conflicts in VS Code's terminal (not Mac's terminal). In order to fix this, you essentially have to find the symlink for which npm and remove the node_modules and npm associated recursively.
Here's the link you'll need: https://github.com/Microsoft/vscode-docs/blob/master/docs/editor/integrated-terminal.md#why-is-nvm-complaining-about-a-prefix-option-when-the-integrated-terminal-is-launched.
Don't forget to restart your editor after.
Another solution is to implement this. https://medium.com/#kinduff/automatic-version-switch-for-nvm-ff9e00ae67f3
Basically, nvm will check for a .nvmrc and switch or default each time you go to a new directory in shell.
It does have a dependency on zsh.
The fix for me on Ubuntu:
A.) sudo apt-get remove nodejs npm
B.) Removed lines in my .bashrc that added the npm package directory to the path.
C.) Restart VS Code.
I doubt step A is necessary. But B and C certainly are.

Why npm gets stuck when installing browser-sync?

When attempting to install Browser-syn [sudo npm install -g browser-sync] on Ubuntu, it gets stuck, the last readout is [loadDep:is-fullwidth-code].
I have been trying various solutions pertaining issues with npm, to no avail.
I made it to work.
I removed nodejs v4.2.6 (that came with Ubuntu 16.04), an old package manager npm was also removed.
I installed nodejs v6.11.5 (that came with npm v3.10.10) following instructions on https://nodejs.org/en/download/package-manager/.
I used npm to install browser-sync [$ sudo npm install -g browser-sync]
as indicated on https://www.browsersync.io/.
It worked this time.

Cannot install phantomJS in Karma

WARN [config]: config.configure() is deprecated, please use config.set() instead.
WARN [plugin]: Cannot find plugin "karma-phantomjs".
Did you forget to install it ?
npm install karma-phantomjs --save-dev
INFO [karma]: Karma v0.10.2 server started at http://localhost:9018/
WARN [launcher]: Can not load "PhantomJS", it is not registered!
Perhaps you are missing some plugin?
Getting this error. When running npm install karma-phantomjs --save-dev I get an error.
npm ERR! 404 'karma-phantomjs' is not in the npm registry.
I installed karma-phantomjs-launcher --save-dev but i still get an error when running grunt watch.
Anyone else run into this issue?
npm install karma-jasmine --save-dev
npm install karma-phantomjs-launcher --save-dev
Then add the following line to karma.config.js
plugins : ['karma-jasmine', 'karma-phantomjs-launcher']
I got tripped up by this today running
karma: 0.13.7
karma-phantomjs-launcher: 1.0.0
What isn't very obvious is that the launcher has a dependency on:
phantomjs-prebuilt
So if you, install this locally everything should run fine, eg:
npm install phantomjs-prebuilt --save-dev
After some research I realized that I needed to run:
npm install -g karma#canary phantomjs karma-phantomjs-launcher
Once I ran that I went back into my karma-unit.tpl.js file and instead of karma-phantomjs, I changed this to karma-phantomjs-launcher.
Now when I execute a command like grunt build, I get no error regarding phantomJS
This is an issue still open on the repo: #31
Strangely enough the following worked for my Debian based system:
apt-get install libfontconfig
How did I get into this? Reading a comment from the ticket. Hope this will help for others too :-)
I'm running in a CentOS 7 Docker container. Had similar issue.
Had to:
yum install -y tar bzip2 freetype fontconfig
Then
npm install phantomjs --save-dev
worked without errors, which allowed
npm install karma-phantomjs-launcher --save-dev
and that allowed
gulp test
to run without Karma or PhantomJS errors.
Today I had the same. I deleted all the temporary directories and, after rerun it worked.
Before that i also reinstalled phantomjs but without success. It's possible that this influenced, anyway (but i think deleting the temporary directories did the job). Anyway, after deleting temporary folders you can try, if it didn't work you can reinstall phantomjs and also other stuff as other users already wrote.