Running Express.js in Windows 7 - javascript

I tried install express (using -g for global) in Windows 7 using
npm install -g express
I get the following and no errors:
npm http GET https://registry.npmjs.org/express
...
npm http GET https://registry.npmjs.org/mime/-/mime-1.2.11.tgz
npm http 200 https://registry.npmjs.org/mime/-/mime-1.2.11.tgz
npm http 304 https://registry.npmjs.org/debug/0.8.0
express#4.1.1 C:\Users\xxx\AppData\Roaming\npm\node_modules\express
├── methods#0.1.0
├── parseurl#1.0.1
..
├── type-is#1.1.0 (mime#1.2.11)
└── accepts#1.0.1 (negotiator#0.4.3, mime#1.2.11)
When I type express, I get:
'express' is not recognized as an internal or external command.
Any idea why this would happen?

I ran into the same problem on Windows 8.1
use this command
npm install -g express-generator
or
npm install -g express-generator#'version'
like
npm install -g express-generator#3

Express is not meant to be run on command prompt.
If you're trying to generate the base express project then you can use express-generator, you can install it using:
npm install -g express-generator
After success installtion, then to generate an express project:
Go the directory on your hard drive.
run the following command: express myProject
It will generate the base project for you.
using your command prompt go to the created folder by the previous command.
you can run now your project using one of the following commands:
npm start OR node myProject

Related

Can I install react native Cli through terminal globally?

I want to install react-native cli but I don't where to run this command: npm install -g react-native-cli. Do I need to run this command on my macOS terminal or when I will make a directory for my react native app then there I need to run this command in vscode?
Is there any issue if I run this command in my terminal or If I run this in VScode?
React Native is distributed as two npm packages, react-native-cli and react-native.
The first one is a lightweight package that should be installed globally (npm install -g react-native-cli), while the second one contains the actual React Native framework code and is installed locally into your project when you run react-native init.
Because react-native init calls npm install react-native, simply linking your local GitHub clone into npm is not enough to test local changes.
npm install –g react-native-cli
· This line installs the npm package react-native-cli along with its dependencies(from the npm repository host) inside the globally shared node_modules folder.
· Global install (with -g): puts stuff in /usr/local or wherever node is installed. This will also allow you to access the module from the command-line, as the bin is symlinked into a PATH folder (usually usr/local/bin).
Refer below link
https://rlogicaltech.medium.com/how-to-install-react-native-on-mac-step-by-step-guide-1ac822aedd4f
You can run the command anywhere in the terminal.
It will install the react-native-cli globally as we are specifying the "-g" option in the command.
Use this
npm install -g expo-cli
this how I solved it.
npm install -save react-native#latest

Why the express module is not installing in its default directory e.g., npm\node_modules?

I'm trying to install express module using the following commands:
npm install --save express
npm install -g express
npm install -g express-generator
After installation I was expecting the module to be created inside nodejs\node_modules\npm\node_modules, Instead it is getting installed and created in somewhere else (In C:\Users\$SudoName\AppData\Roaming\npm\node_modules).
Therefore while running the project node is unable to locate the express module in it's own directory where it suppose to be.
Let's explain your commands step by step:
$ npm install --save express
The --save command is used when you want to save a package for distribution. This command saves the package under your dependencies section of your package.json file.
$ npm install -g express
From the documentation: "In global mode (ie, with -g or --global appended to the command), it installs the current package context (ie, the current working directory) as a global package.".
In your case: C:\Users\$SudoName\AppData\Roaming\npm\node_modules
Note: You can see where your packages are installed using:
$ npm list -g
Finally,
$ npm install -g express-generator
gets the same approach. It gets installed under your global dependencies.

Getting error Cannot find module 'cryptile' while installing express js

I am new to node js and facing issue in installing express js. Please help in fixing the issue and install express js.
Now when i tried to install cryptiles module using the command "npm install cryptiles" i am getting the same error.
Just run npm install cryptiles then re-run your previous command
or if you don't want then go to your packages.json file and remove the dependency...
UPDATE :
Seems this package isn't supported anymore ..
To see yourself install globally:
npm install -g cryptiles
then install try to install in source destination
npm install cryptiles
You should get the following message:
npm WARN install Couldn't install optional dependency: Unsupported

npm: not found when setting up Jenkins Server?

This is my first time setting up a jenkins server. The build is using Amazon's EC2 and Ubuntu 14.04.
I've installed node and npm via nvm.
node -v
>v0.11.14
npm -v
>2.0.0
The repo pulls down just fine into my /var/lib/jenkins/workspace/morningharwood folder.
Problem: When I add my script it breaks
Here's my build script which errors out? I have no idea what i'm doing. I copied this from a tutorial.
QUESTION: How do I properly write my script to npm install, bower install and lastly, grunt test
You could install node, npm, bower and grunt by doing following:
sudo apt-get install node
sudo npm install bower
sudo npm install grunt
To install a package from local source, use
npm install /path
Try using NodeJS plugin for Jenkins: https://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin
This will solve npm command not found issue on jenkins even installed on server
sudo mkdir /usr/local/nvm
export NVM_DIR=/usr/local/nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh |NVM_DIR=/usr/local/nvm bash
. /usr/local/nvm/nvm.sh
nvm install 10.15.3 -g
npm install #angular/cli -g
Include following on build execute shell command in jenkins:
export PATH="$PATH:/usr/local/nvm/versions/node/v10.15.3/bin"
npm install

Error in npm for npm install selenium-webdriver

I am using Windows Server 2008 R2 EE OS. In which I have npm package manager. I am trying to run the below command to install Selenium Webdriver package.
Command:
npm install selenium-webdriver
I am receiving below error while doing it.
Error:
node.js npm should be run outside of the node repl in your normal
shell
You are running the npm command inside the node shell.
Open another shell and just type "npm install bla-bla", npm should be on the PATH. Or cd to its directory and type command.
See my command images
Doing it wrong
Doing it right
In the case of windows, sometimes it is bad to consider that the npm will create folder itself for what it required.
The best is to manually create npm folder like "C:\Users\username\AppData\Roaming\npm".
Hope this help.
By creating a folder C:/Users//AppData/Roaming/npm solved my problem.

Categories