Node.jsはExpressアプリケーションのいくつかのステップをすばやく作成します

Node.js Expressフレームワークの学習

 

転載および参照住所:

https://developer.mozilla.org/zh-CN/docs/Learn/Server-side/Express_Nodejs/development_environment

https://developer.mozilla.org/zh-CN/docs/Learn/Server-side/Express_Nodejs/skeleton_website

 

1.フォルダを作成します

2. cmdコマンドの下に、現在のフォルダーを入力します

3. npm環境を初期化します(それ以外の場合、直接ダウンロードモジュールはエラーを報告します)

npm init -y

4. Expressモジュール、ジェネレータージェネレーターをインストールします。

npm install express 

npm install -g express-generator

5.アプリケーションディレクトリに入り、次のコマンドを実行して、「helloworld」という名前のExpressアプリケーションを作成します。

helloworldを表現する

プロジェクト名を指定しない場合、Expressアプリケーションはデフォルトで現在のディレクトリに生成されます。次のスクリーンショットはこの使用法です。

  ================================================== =====================

Expressアプリケーションの作成後、システムは次のプロンプトを表示します。:
\ 006_Project__nodejs \ Demo2> express --view = pug
destination is not empty、continue?[Y / N] y

create:public \
create:public \ javascripts \
create:public \ images \
create:public \ stylesheets \
create:public \ stylesheets \ style.css
create:routes \
create:routes \ index.js
create:routes \ users.js
create :views \
create:views \ error.pug
create:views \ index.pug
create:views \ layout.pug
create:app.js
create:package.json
create:bin \
create:bin \ www

インストールの依存関係:
> npm install

アプリを実行します。
> SET DEBUG = demo2:*&npm start
下の2行のコマンドは非常に重要です。
================================================== =====================

6.次のコマンドを使用して、helloworldアプリケーションのすべての依存関係をインストールします。

cd helloworld 

npm install

7.次に、このアプリケーションを実行します(Windows環境):

> SET DEBUG = helloworld:*&npm start

(Linux / macOS環境):

$ DEBUG = helloworld:* npm start

8.ブラウザを開き、http://127.0.0.1:3000 /にアクセスします。Expressのデフォルトのウェルカムページが表示されます。

 

おすすめ

転載: www.cnblogs.com/music-liang/p/12687593.html