Express Command Not Found in Windows 10

Asked 2 years ago, Updated 2 years ago, 323 views

Regarding the title, I am at a loss because I am unable to proceed with the study.
The following are the steps up to the event.Please let us know your knowledge.

What you want to resolve
I want to be able to use the express command.

Install
I downloaded the installer from the official website and installed it as it was.
(ver is 16.13.1 LTS, and the settings have not changed.)

Install Express-generator with the npm command
We installed Express and Express-generator globally using the npm command.
Image shows the installation status.

After installation, I checked the root folder just in case.
As shown in the picture below, the package seems to be installed in the root folder without any problems.
prompt
folder

Cannot create application with Express command...
Now that the required package has been installed,
"We used the official website guide (https://expressjs.com/ja/starter/hello-world.html) until the ""Hello world"" output at localhost:3030."

At this time,

on the source code
const express=require('express')

I thought express could work properly because worked fine.

Then I tried to create a web application using the express command, but

$express-vejs express-app

The express command could not be found and was completely blocked.
Enter a description of the image here

What else have you tried
Global installation failed, so I tried local installation on my desktop, but I couldn't find the command in the same way...
Local Install

These are the steps.

I would appreciate it if you could let me know if you need any other information.
Sorry for the inconvenience, but I appreciate your cooperation.

node.js windows-10 express.js

2022-09-30 22:01

1 Answers

From Edit Environment Variables on the control panel (which is faster when searched in the Start menu), make sure that the PATH of the user environment variable contains the path to which the npm package is installed globally.

Enter a description of the image here

Enter a description of the image here

If you do not have %USERPROFILE%\AppData\Roaming\npm here, please add it.(%USERPROFILE% is actually your home directory)

If the installer was in the default state, it should have already been included.
(Sometimes you can't add more characters if you're installing a variety of things.)

Close and reopen all currently open command prompts, PowerShells, etc., or restart your PC.(Probably no reboot is required, but that's more certain)

Is the express command now available?The express command is included in the express-generator instead of the express package.

The npm provides a tool command called npx.This allows you to execute commands for packages that are installed in npm, even if the path is not passing, or if you have not explicitly installed them.

npx express --version

Local, Global, AutoInstall should be searched and executed with priority.(However, if you do not explicitly install it, express-generator must specify it because the package name is different.)


2022-09-30 22:01

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.