美文网首页
Node工程快速入门

Node工程快速入门

作者: 明训 | 来源:发表于2021-04-23 21:17 被阅读0次

背景说明

Node环境安装完成后,这里创建一个简单的工程进行入门

解决方案

创建项目

创建目录nodedemo

$ mkdir nodedemo
86183@LAPTOP-CRFK470 MINGW64 /c
$ ls
nodedemo/
86183@LAPTOP-CRFFK470 MINGW64 /c
$ cd nodedemo/
86183@LAPTOP-CRFFK470 MINGW64 /c/nodedemo
$

初始项目

通过node init命令初始化项目

86183@LAPTOP-CRFFK470 MINGW64 /c/nodedemo
$ 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 init` 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: (nodedemo)
version: (1.0.0)
description:
entry point: (index.js)
test command:
git repository:
keywords:
author:
license: (ISC)
About to write to C:\nodedemo\package.json:
{
  "name": "nodedemo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}
Is this OK? (yes)
86183@LAPTOP-CRFFK470 MINGW64 /c/nodedemo
$

经常用Git的可能都会觉得git bashcmd好用一些,不仅在样式上,git bash还支持sshlscpmvvi这些Linux常见命令

可以看到生成了一个文件

86183@LAPTOP-CRFFK470 MINGW64 /c/nodedemo
$ ls
package.json

文件内容如下

{
  "name": "nodedemo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

ISC开源协议参见文档:https://opensource.org/licenses/ISC

编写脚本app.js

var greeting='hello wold nodejs';
console.log(greeting)

项目运行

$ node app.js
hello wold nodejs
86183@LAPTOP-CRFFK470 MINGW64 /c/nodedemo
$

相关文章

  • Node工程快速入门

    背景说明 Node环境安装完成后,这里创建一个简单的工程进行入门 解决方案 创建项目 创建目录nodedemo 初...

  • 前端Node.js 基础

    一 .Node.js 基础 目录 Node开发概述Node运行环境搭建Node.js快速入门 1. Node开发概...

  • brew不能安装node.js

    想学习React Native,查看快速入门,需要依赖node.js。使用brew install node命令即...

  • Node快速入门

    nodejs 先说说各大语言之间的差异,网上经常有人说,Java程序员鄙视php程序员,当然这只是个笑话 我想说的...

  • WebDriver 的协议标准 W3C

    Selenium WebDriver 快速入门工程: https://github.com/Jason-Chen-...

  • 笔记

    【入门】WEEX快速创建工程 Hello World - willspace - SegmentFault ht...

  • node爬虫快速入门

    node爬虫 初入前端,刚刚接触node,对于耳闻已久的node爬虫非常神往,所以有了这篇文章,项目代码在文章末尾...

  • Weapy笔记

    官方文档 快速入门 安装 生成工程 进入工程目录 实时编译项目 wepy build --watch 注意事项: ...

  • SpringBoot快速入门

    SpringBoot快速入门 用Intellij Idea快速建立一个SpringBoot工程,新建一个Proje...

  • node相关学习资料(+)

    官方文档Node.js v6.2.0 Documentation 快速入门教程菜鸟教程 阮一峰es6入门教程ECM...

网友评论

      本文标题:Node工程快速入门

      本文链接:https://www.haomeiwen.com/subject/bpyhrltx.html