I cannot install nodemon by using npm command - node.js

enter image description here
When i tried to install nodemon package using npm i got errors as shown in the picture. I also tried using sudo but nothing changed.

you can use this command.
sudo npm install nodemon -g
sudo makes sure that the command would run as a superuser that allows users to run programs with the security privileges of another user (normally the superuser, or root).
-g instructs npm to install the node package globally onto the system.

Related

Install reactjs on ubuntu 18.04

Node
curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
sudo apt-get install -y nodejs
npm 5.3+
sudo npm install npm#latest -g
Create-React-App
npm install -g create-react-app
create-react-app memory
When i enter "npm start", the application does not open on the browser and I can not access it via the url my.ip.public:3000.
I disabled the firewall, it does not solve the problem. I granted another port via an .env file, it did not solve the problem.
It is not a question of duplication because on the link the command "npm start" does not produce any effect, with me everything seems correct at the level of the command line ... besides, I tried the solution of your link but that does not solve the problem, it makes it worse.
This will generate an error like Error: EACCES: permission denied, access '/usr/local/lib/node_modules' react
You need a superuser privilege to install react. To get superuser privilege simply run
sudo -i
command before the command npm install -g create-react-app
I was having problems with this also but here is what worked for me
Make sure you have npm installed or use:
sudo apt install npm
Then
sudo npm -g install create-react-app
after that I used this for creating an app (don't use npm followed by the rest, instead us as follows):
create-react-app nameofyourapp
That worked for me.

How to install node/npm so that 'sudo npm' works on an ec2 instance?

Answer: Follow the steps in this link
http://iconof.com/blog/how-to-install-setup-node-js-on-amazon-aws-ec2-complete-guide/
I am running ubuntu on an ec2 instance and need to sudo npm install something. I am given the error that sudo npm is not recognized.
There is a previous thread that is 7 years old. On EC2: sudo node command not found, but node without sudo is ok I tried every solution there and nothing worked.
I think the problem is using NVM to install npm and node. How can I install these so that they are compatible with sudo? Thanks!
You can run the following command
sudo yum install nodejs npm --enablerepo=epel
For more, you can also install using the following link also: https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html
Second Approach:
Install NPM
git clone https://github.com/isaacs/npm.git
cd npm
sudo env PATH=$HOME/local/node/bin:$PATH make install
Now you can install npm packages and run javascript node files as usual!
sudo npm install forever -g
sudo npm install express -g
Resource Link: http://www.wisdomofjim.com/blog/how-to-install-node-and-npm-on-an-ec2-server
You can use NVM. You can follow this link which gives proper steps to install node on ec2 instance.
I dont know if my problem is the same as yours (i think is similar), but i tried to run "sudo npm install" on a amazon linux ec2 machine and it gave me the "sudo: npm: command not found" type of problem.
I followed the instructions recommended by AWS to install node and NPM (https://docs.aws.amazon.com/sdk-for-javascript/v2/developer-guide/setting-up-node-on-ec2-instance.html).
I solve this by changing the owner and group of the directory and files (package.json and package-lock.json):
chown ec2-user:ec2-user nameDir
and then i run npm install again. It worked!

getting error when using -g in npm

when I try to install any package globally, I get multiple errors. have a look at the image
the errors in the terminal
Thanks all.
When you install any global package just add sudo prefix. sudo npm install -g express
If you want to install packages globally with the "g"-parameter you must be root.
It's easy to just run sudo npm install -g express to successfully install express.
But a long time solution for the permission access, run chown -R YOUR_USERNAME /usr/lib/node_modules from your terminal so that you will not have to include sudo in your subsequent installation using -g

Is `prefix ~/.npm-packages` the same as `prefix=${HOME}/.npm-packages`

I am not able to run npm install npm#latest -g without running into permissions errors and being forced to use sudo npm install npm#latest -g. I had been able to run this without using sudo, however, I followed an answer on StackOverflow that suggested using sudo and this seemed to mess things up. (I was never able to upgrade npm.)
Trying to rectify this sudo issue, I found a potential solution follow here, "Install npm packages globally without sudo on macOS and Linux"
https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md
Step 2 says: "2. Indicate to npm where to store globally installed packages. In your ~/.npmrc file add: prefix=${HOME}/.npm-packages"
When I open the ~/.npmrc file, I see prefix=~/.npm-packages. Is prefix ~/.npm-packages the same as prefix=${HOME}/.npm-packages, or do I need to add ${HOME}?
I am running Mac 10.11.6. My npm is at v 5.6.0.
In many shells "~" is an alias for ${HOME}. Using ${HOME} gets the shell to insert the Home environment variable and is more universal then "~".

Fix for npm global install on Ubuntu

I have a nodejs package that requires a global install. This one fails in a way that leads me to believe there might be a configuration problem in the the Ubuntu package npm. This happens every-time I setup an Ubuntu 14.04 machine.
sudo apt-get install npm
npm install -g lineman
The npm -g command will throw some access error naming the local lib and bin directories. Unlike some global installs, it is not an option to cheat and run the second command under sudo. So, the only fix I have found that will work is something like this:
sudo chgrp -R $(whoami) /usr/local/bin /usr/local/lib
sudo chmod -R g+rwx /usr/local/bin /usr/local/lib
The fix is fine for me, I'm the only user. But is this really the best way to do it? I don't want to document my fix for anyone else that might use it in an environment where this will not work or cause trouble.
Also, should I file a bug report with someone who packages npm for Ubuntu?
Instead of npm install -g lineman, you should run sudo npm install -g lineman. npm requires permission as well.
Also check this stackoverlfow link.

Resources