如何创建一个node项目?

创建一个node项目的方法:使用命令mkdir EmojiImages创建一个项目,使用命令npm init然后一直回车完成初始化,最后在EmojiImages目录中编写js文件就可以了。

创建一个node项目的方法步骤:

创建项目目录

mkdir EmojiImages

初始化

npm init

一直回车确认:

This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help json` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg>` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
package name: (emojiimages)
version: (1.0.0)
description:
entry point: (index.js)
test command:
git repository:
keywords:
author:
license: (ISC)
About to write to /Users/diyuanwang/github/EmojiImages/package.json:

{
  "name": "emojiimages",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}
Is this OK? (yes)

这时候我们已经完成了nodejs项目的初始化工作。

我们得到了一个目录和一个文件EmojiImages/package.json

剩下的工作就是编写js文件了。

使用WebStorm 打开目录,并创建index.js

1 (2).jpg-600

以上就是如何创建一个node项目?的详细内容,更多请关注0133技术站其它相关文章!

赞(0) 打赏
未经允许不得转载:0133技术站首页 » Node.js答疑