zoukankan      html  css  js  c++  java
  • nodejs学习

    创建一个Nodejs项目

    npm init 生成 package.json

    hongyun@ubuntu:/opt/vue/test$ 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: (test) 
    version: (1.0.0) 
    description: test 
    entry point: (index.js) 
    test command: 
    git repository: 
    keywords: 
    author: 
    license: (ISC) 
    About to write to /opt/vue/test/package.json:
    
    {
      "name": "test",
      "version": "1.0.0",
      "description": "test ",
      "main": "index.js",
      "scripts": {
        "test": "echo "Error: no test specified" && exit 1"
      },
      "author": "",
      "license": "ISC"
    }
    
    
    Is this OK? (yes) 
    
    
       ╭─────────────────────────────────────────────────────────────────╮
       │                                                                 │
       │      New patch version of npm available! 6.14.86.14.11       │
       │   Changelog: https://github.com/npm/cli/releases/tag/v6.14.11   │
       │                Run npm install -g npm to update!                │
       │                                                                 │
       ╰─────────────────────────────────────────────────────────────────╯
    
    hongyun@ubuntu:/opt/vue/test$ 

    "main": "index.js" 这个项目的入口是index.js

    安装一个模块

    npm install express@3.21.2

    hongyun@ubuntu:/opt/vue/test$ ll
    total 44
    drwxrwxr-x  3 hongyun hongyun  4096 2月   1 09:28 ./
    drwxrwxr-x  3 hongyun hongyun  4096 2月   1 09:15 ../
    drwxrwxr-x 80 hongyun hongyun  4096 2月   1 09:28 node_modules/
    -rw-rw-r--  1 hongyun hongyun   255 2月   1 09:28 package.json
    -rw-rw-r--  1 hongyun hongyun 25441 2月   1 09:28 package-lock.json
    hongyun@ubuntu:/opt/vue/test$ cat node_modules/express/index.js 
    
    module.exports = require('./lib/express');
  • 相关阅读:
    GEF: 图形拖拽处理
    【矩阵快速幂】bzoj1297 [SCOI2009]迷路
    【扩展欧几里得】NOIP2012同余方程
    【高精度乘法】NOIP2003麦森数
    【数论·错位排列】bzoj4517 排列计数
    【数论】Lucas
    【NOIP2012】疫情传递
    【NOIP2012】旅行计划
    【Manacher算法】求最长回文串的优秀算法
    【Tarjan】洛谷P3379 Tarjan求LCA
  • 原文地址:https://www.cnblogs.com/perfei/p/14355144.html
Copyright © 2011-2022 走看看