npm install is successful but not able to run the programs - javascript

I am trying to install the http-server, bower, grunt in my windows machine. I tried to install using npm install the install is successful but when, i try to run the command it is saying command not found. I tried closing the command prompt and execute again. Same result. The file are available in appdata folders.
C:\Users\testuser>npm install http-server
+ http-server#0.11.1
updated 1 package in 5.713s
C:\Users\testuser>http-server
'http-server' is not recognized as an internal or external command,
operable program or batch file.
I tried listing the services and the service is installed
C:\Users\testuser>npm list -g --depth=0
C:\Users\testuser\AppData\Roaming\npm
+-- bower#1.8.4
+-- http-server#0.11.1
`-- json-server#0.12.1
I tried searching for similar issues, but could not find the same.

npm install http-server -g
This will install http-server globally so that it may be run from the command line.

Related

What is difference between local and global Node package installation?

I ask this question because I have been installing nodemon with npm and I see the results of installing through the suggested command at first sight, at the right side of the screen:
npm i nodemon
It is different from the installation instructions you can read above, on the Installation section. There we see:
global installation:
npm install -g nodemon
install nodemon as a local project dependency:
npm install --save-dev nodemon
The thing is, what is difference between
npm i nodemon
and
npm install -g nodemon
When I use the first command it tells me typical "nodemon is not recognized as internal or external command, operable program or batch file". To solve it I must install globally.
When you run npm i nodemon nodemon is installed as a local project dependency, to run nodemon on the CLI you would have to provide the pull path to it's installation, typically you would want to make this reference in your project's package.json file's scripts property, for instance:
{
...
"scripts": { "nodemon": "nodemon index.js" },
...
}
This can then be executed by running npm run nodemon.
On the other hand running npm install -g nodemon or npm i -g nodemon installs nodemon on the global scope where it is referenced in your system PATH variable, that way you can easily call nodemon on the CLI and since it's full installation path is referenced in your system PATH variable it would execute like every other CLI command.
Browser is made available to the current project (where it keeps all of the node modules in node modules) after local installation. It will not be available as a command that the shell can resolve until you install it globally with npm install -g module, in which case npm will install it in a location where your path variable will resolve this command. Typically, this is only good for using a module like so var module = require('module');
This documentation will help.

How do I remove yarn from angular cli. I want to use npm to install packages

Installing packages for tooling via yarn.
An unhandled exception occurred: 'yarn' is not recognized as an internal or external command,
operable program or batch file.
Package install failed, see above.
See "C:\Users\hp\AppData\Local\Temp\ng-TAwQZJ\angular-errors.log" for further details.
This is the error in my terminal everytime I try to install any package.
I have tried "npm uninstall -g yarn" nothing happens. I tried in control panel to find any yarn package but nothing.
How can we do this and install packages via npm?
try either of
ng config --global cli.packageManager npm
or
ng set --global packageManager=npm
Also, Yarn is faster and better as per some blogs,
So you can keep yarn as default package manager and install it
https://classic.yarnpkg.com/en/docs/install/

does npm install command for node package manager runs npm build automatically

I have integrated a reusable node js project to azure and published the node project to azure artifact store for npm using command 'npm publish'.
And i have a azure task in pipeline which uses this reusable package in my main project with yaml content like below:
npm install <my reusable package name from internal azure npm registry>
npm install //this installs all other packages based on main project's package.json
Does npm command 'npm install ' runs 'npm build' command right after downloading package ? if it does then i do not want to buid my npm package before publishing.
I want to make sure when someone install my reusable package the dist folder is available.
e.g. When i install npm package 'vue-tabulator' after installation i noticed it populated dist folder. I am not sure if this happens for all the packages.

npm install couldnt install angularjs libraries

I have installed mean.io and ran sudo npm install. Actually following commands in sequence
sudo npm install -g meanio
mean init yourNewApp
cd yourNewApp
sudo npm install -g bower
sudo npm install
It is supposed to download and install angularjs libraries into public/system/lib. After doing the above steps public /system/lib is not created due to which when I start the application I get the error
events.js:72
throw er; // Unhandled 'error' event
^
Error: ENOENT, open '/home/santhosh/dev/scaleqa/mean_tut/old mean/temp/myapp/public/system/lib/bootstrap/dist/css/bootstrap.css'
[nodemon] app crashed - waiting for file changes before starting...
Is it something to do with certain npm/angularjs server being down. I have faced this problem earlier also but got fixed on 2nd try and I didn't bother to do more research. This became a big issue when I try to pull my repo into cloud and start the application. public/system/lib is added in .gitignore by default and is expected to be created during npm install.
I get following warnings with sudo npm install
npm WARN package.json mean-connect-mongo#0.4.3 No repository field.
npm WARN cannot run in wd mean#0.3.3 node node_modules/bower/bin/bower install (wd=/home/santhosh/dev/scaleqa/mean_tut/old mean/temp/myapp)
this is link to package.json
The problem maybe related to running npm install as sudo, which can cause problems. As mentioned in another stack overflow question, this can be worked around in a couple ways. But because it looks like this is being run from your home directory, you really shouldn't need to run npm install as root.
Try to issue the same commands, but the last without sudo:
sudo npm install -g meanio
mean init yourNewApp
cd yourNewApp
sudo npm install -g bower
npm install
Note that the reason you may need to run npm install -g <package> using sudo is because by default npm uses /usr/local for global installs, which can be a restricted directory. However, when you install a package locally (without the -g flag) you should not need to run as root.

Grunt server: command not found in terminal

In my project directory, I installed Grunt by using the following command:
npm install grunt
...after that I did Grunt server in my project directory but it gives me command not found error.
Raj$ grunt server
-bash: grunt: command not found
And:
npm install grunt
npm WARN package.json BID-2.0#0.0.0 No description
npm WARN package.json BID-2.0#0.0.0 No repository field.
npm WARN package.json BID-2.0#0.0.0 No README data
How can I fix it?
You need to install Grunt's command line interface (CLI) globally as well.
From their site:
npm install -g grunt-cli
You may need to use sudo command (for OSX, *nix, BSD etc) or run your command shell as Administrator (for Windows) to do this.
This will put the grunt command in your system path, allowing it to be run from any directory.
You will have to install grunt after installing node / npm with: npm install -g grunt. Then it will be available at the cmd.

Categories

Resources