I am having issues trying to install nestJS for my MacBook and this error keeps popping up in my terminal when I use $ npm install -g #nestjs/cli . Am I doing something wrong or am I not putting this command line in the right place? Please help :)
Running the command as sudo is only a temporary solution as you generally want to have access to this directory as a regular user and you will undoubtedly run into future issues working with node_modules.
The right approach is to change the ownership on this directory so you don't need to use elevated permissions to interact with it.
sudo chown -R $USER /usr/local/lib/node_modules
I'd like to break the bad habit of installing npm global packages by using sudo.
I already have seen answers about how to avoid sudo by switching to using your home directory, like this: Ensure npm install -g does not need sudo?
But I've already installed a bunch of stuff globally using sudo. I want to take all that stuff with me that's installed as root into my new home directory for npm. Is there a way to do that, or am I essentially starting over from scratch having to re-install everything that I had installed before?
Having not seen a better answer yet, I went forward with doing this:
npm list -g --depth=0
...to see what I already had installed globally. Then I followed the steps here: https://docs.npmjs.com/getting-started/fixing-npm-permissions
...to set up npm in my home directory, then I reinstalled everything (which turned out not to be a huge amount of stuff) I got from "npm list -g --depth=0".
So far, so good. I'd still be curious to know if there's a better approach.
I'm something of a Cygwin newbie, so that might be the problem, but I'm trying to install a package using apt-get and it's telling me there's no such command. I installed it on Windows 7.
The best I got from searching other questions here and across the net was that you need to install something specific (or run the setup file to update) when initially installing, but it's not clear to me what I need to install or run or whatever.
How do I install or update my cygwin to be able to use apt-get or, alternatively, how would I install packages with the basic, default installation of Cygwin that I already have?
Thank you.
You can use this : apt-cyg
It works just like apt-get in terms of command line arguments, but you will be using apt-cyg instead.
Refer https://github.com/transcode-open/apt-cyg It did helped me.
To install apt-cyg package.
Cygwin's official installer is setup.exe. This is the "proper" way to install Cygwin packages. There's a project called cyg-apt but it's not officially part of Cygwin.
I am trying to install iperf on ubuntu 11.10. I refer this site to install.
After I gave ./configure, the error would be "bash: ./configure: No such file or directory"
Then, i found out where is configure, and I have given command as ./iperf-2.0.5/configure. Then i have followed further step given by that link.
But, If I give iperf -s -D command, I am getting the error as given below:
The program 'iperf' is currently not installed. You can install it by typing:
sudo apt-get install iperf
What mistake have I done? Please point it out.
Thank you in advance!!!
You should really read what that error message said. If you simply run command:
sudo apt-get install iperf
you will get iperf installed without the need to compile it from source - at least it did for me.
That said, please consider using (or least trying) more modern equivalent of iperf, namely nuttcp. nuttcp seems to be better supported, and, according to some sources, works better.
You can install nuttcp on Ubuntu using:
sudo apt-get install nuttcp
I would have commented on mvp's answer, but unfortunately I do not have enough reputation at the moment.
First of all, to cover your question, if you are building from source like you do, after you run the "configure" script, you should:
sudo make
and then
sudo make install
in the folder that the configure script is located, so in your case in "iperf-2.0.5" folder.
Having said that, I highly suggest that you drop iperf version 2 and move to iperf version 3. As somebody that uses iperf to examine and teach protocols, I believe it follows the protocols much more closely and behaves more predictably.
You can download the source form: https://code.google.com/p/iperf/ and the instructions to install it are similar with the ones you followed and can be found in the README file in the tarball.
I am being more cautious than usual because I have been confused by the behavior of npm in the past.
I am on a Mac and have installed node.js through brew install node.
Now that I want to run jslint.js on the command-line as the command jslint I find that the canonical way to accomplish this is sudo npm install -g jslint which ran successfully with this output:
$ sudo npm install -g jslint
npm http GET https://registry.npmjs.org/jslint
npm http 200 https://registry.npmjs.org/jslint
npm http GET https://registry.npmjs.org/jslint/-/jslint-0.1.9.tgz
npm http 200 https://registry.npmjs.org/jslint/-/jslint-0.1.9.tgz
npm http GET https://registry.npmjs.org/nopt
npm http 200 https://registry.npmjs.org/nopt
npm http GET https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz
npm http 200 https://registry.npmjs.org/nopt/-/nopt-1.0.10.tgz
npm http GET https://registry.npmjs.org/abbrev
npm http 200 https://registry.npmjs.org/abbrev
npm http GET https://registry.npmjs.org/abbrev/-/abbrev-l.0.4.tgz
npm http 200 https://registry.npmjs.org/abbrev/-/abbrev-1.0.4.tgz
/usr/local/share/npm/bin/jslint -> /usr/local/share/npm/lib/node_modules/jslint/
bin/jslint.js
jslint#0.1.9 /usr/local/share/npm/lib/node_modules/jslint
└── nopt#1.0.10 (abbrev#1.0.4)
Subsequently
$ jslint ply.js
zsh: command not found: jslint
due to /usr/local/share/npm/bin not being in my $PATH.
1) Why did brew not install global npm bin path to path? Maybe it did, but something zsh does is messing it up. Where might I be able to find that?
2) Should I do this? (Append :/usr/local/share/npm/bin to the exported $PATH at the bottom of my ~/.zshrc)
It seems like this isn't the right way to do it because if I install something else later (using Homebrew or something) I'll be needing to append it to my zsh startup script to set the path. I guess in this particular instance it's just a matter of the npm install -g not making the right symlinks in a "proper" location (like /usr/local/bin maybe).
I think what I will do is manually build out symlinks inside /usr/local/bin for any programs that I have trouble with and it should be good enough for my purposes.
EDIT: I'm updating this in 2019, because this old question is popular but now outdated both in terms of my personal workflow and also in terms of how to best go about installing node and managing its various dependencies.
My personal workflow is now to use the installer obtained from nodejs.org to install node on systems. I actually trust this more than the homebrew package itself, because it knows best how to manage the files. If you want to change your system node from 8.10 to 10.15, whether on Mac or Windows, simply download the installer from nodejs.org for 10.15 for your OS. Attempting to upgrade node installed via homebrew has always proven to be a more difficult approach in my experience.
Also, the biggest thing to point out is that the use of sudo as shown in my npm install of jslint example above is highly discouraged; I am fairly certain that homebrew packages should never be installed or interacted with in any way using the superuser. It should not be necessary, and will lead to file permission headaches!
Furthermore I recommend ESLint over jslint, and have not used jslint in years.
Extending your PATH with:
export PATH=/usr/local/share/npm/bin:$PATH
isn't a terrible idea. Having said that, you shouldn't have to do it.
Run this:
npm config get prefix
The default on OS X is /usr/local, which means that npm will symlink binaries into /usr/local/bin, which should already be on your PATH (especially if you're using Homebrew).
So:
npm config set prefix /usr/local if it's something else, and
Don't use sudo with npm! According to the jslint docs, you should just be able to npm install it.
If you installed npm as sudo (sudo brew install), try reinstalling it with plain ol' brew install. Homebrew is supposed to help keep you sudo-free.
Spent a while on this issue, and the PATH switch wasn't helping. My problem was the Homebrew/node/npm bug found here - https://github.com/npm/npm/issues/3794
If you've already installed node using Homebrew, try ****Note per comments that this might not be safe. It worked for me but could have unintended consequences. It also appears that latest version of Homebrew properly installs npm. So likely I would try brew update, brew doctor, brew upgrade node etc before trying****:
npm update -gf
Or, if you want to install node with Homebrew and have npm work, use:
brew install node --without-npm
curl -L https://npmjs.org/install.sh | sh
I use brew and the prefix was already set to be:
$ npm config get prefix
/Users/[user]/.node
I did notice that the bin and lib folder were owned by root, which prevented the usual non sudo install, so I re-owned them to the user
$ cd /Users/[user]/.node
$ chown -R [user]:[group] lib
$ chown -R [user]:[group] bin
Then I just added the path to my .bash_profile which is located at /Users/[user]
PATH=$PATH:~/.node/bin
I managed to fix Vue Cli no command error by doing the following:
In terminal sudo nano ~/.bash_profile to edit your bash profile.
Add export PATH=$PATH:/Users/[your username]/.npm-packages/bin
Save file and restart terminal
Now you should be able to use vue create my-project and vue --version etc.
I did this after I installed the latest Vue Cli from https://cli.vuejs.org/
I generally use yarn, but I installed this globally with npm npm install -g #vue/cli. You can use yarn too if you'd like yarn global add #vue/cli
Note: you may have to uninstall it first globally if you already have it installed: npm uninstall -g vue-cli
Hope this helps!
brew should not require you to use sudo even when running npm with -g. This might actually create more problems down the road.
Typically, brew or port let you update you path so it doesn't risk messing up your .zshrc, .bashrc, .cshrc, or whatever flavor of shell you use.
In newer MacOS versions you need to edit the .zshrc file not .bash_profile:
In your terminal nano ~/.zshrc
then add the line:
export PATH=$PATH:/Users/[your username]/.npm-packages/bin
Try running:
PATH=$PATH:~/npm/bin
and then do a test by running express in the command line. This worked for me.
If you have linked the node packages using sudo command
Then go to the folder where node_modules are installed globally.
On Unix systems they are normally placed in /usr/local/lib/node or /usr/local/lib/node_modules when installed globally. If you set the NODE_PATH environment variable to this path, the modules can be found by node.
Windows XP - %USERPROFILE%\Application Data\npm\node_modules
Windows 7 - %AppData%\npm\node_modules
and then run the command
ls -l
This will give the list of all global node_modules and you can easily see the linked node modules.
sudo brew is no longer an option so if you install with brew at this point you're going to get 2 really obnoxious things:
A: it likes to install into /usr/local/opts or according to this, /usr/local/shared. This isn't a big deal at first but i've had issues with node PATH especially when I installed lint.
B: you're kind of stuck with sudo commands until you either uninstall and install it this way or you can get the stack from Bitnami
I recommend this method over the stack option because it's ready to go if you have multiple projects. If you go with the premade MEAN stack you'll have to set up virtual hosts in httpd.conf (more of a pain in this stack than XAMPP)plust the usual update your extra/vhosts.conf and /etc/hosts for every additional project, unless you want to repoint and restart your server when you get done updatading things.
Any one got the same issue it's related to a conflict between brew and npm
Please check this solution https://gist.github.com/DanHerbert/9520689
I uninstalled node from homebrew on M1 Apple Silicon and instead used the Mac Installer from https://nodejs.org/en/download/. After doing that I was able to install with npm and npx.
Simple solution is ...
Just put below command :
sudo npm config get prefix
if it's not something like these /usr/local, than you need to fix it using below command.
sudo npm config set prefix /usr/local...
Now it's 100% working fine