zoukankan      html  css  js  c++  java
  • Node.js

    node中npm的使用
    nodejs 软件

    注:终端按两次Ctrl C 退出node

      node -v  查看node版本

      npm -v   看npm版本
    1.安装nodejs 自带了包管理器npm (node package manager)        

                  npm install Bootstrap

                    好比 Python 自带pip    pip install requests

    2.在终端进入当前项目目录,然后初始化目录,会生成一个package.json的文件来管理我们的包()模块(js)
                  npm init   简写为 npm i
                  npm i --yes 直接生成package.json

    {
          "name": "day50",
          "version": "1.0.0",
          "description": "",
          "main": "index.js",
          "scripts": {
                 "test": "echo "Error: no test specified" && exit 1"
          },
          "keywords": [],
          "author": "",
          "license": "ISC",
          "dependencies": {
                 "bootstrap": "^3.3.7",
                 "jquery": "^3.3.1"
           }
    }
    package.json示例


    3.下载当前项目依赖的包

                  npm install jquery@3.4.0 --save 或  npm install jquery@3.4.0 -S

                          自动生成 node_modules文件夹

                  注:从github上下载项目后,在终端cd到该项目目录,执行npm install     自动下载package.json中依赖的所有的包

                                                      卸载  npm uninstall jquery@3.4.0 --save 或  npm uninstall jquery@3.4.0 -S

    {
        "name": "happyfri",
        "version": "1.0.2",
        "description": "vue2-happyfri",
        "author": "cangdu <1264889788@qq.com>",
        "private": true,
        "scripts": {
            "dev": "node build/dev-server.js",
            "build": "node build/build.js"
        },
        "dependencies": {
            "vue": "^2.1.0",
            "vue-router": "^2.1.1",
            "vuex": "^2.0.0"
        },
        "devDependencies": {
            "autoprefixer": "^6.4.0",
            "autoprefixer-loader": "^3.2.0",
            "babel-core": "^6.0.0",
            "babel-loader": "^6.0.0",
            "babel-plugin-transform-runtime": "^6.0.0",
            "babel-preset-es2015": "^6.0.0",
            "babel-preset-stage-2": "^6.0.0",
            "babel-register": "^6.0.0",
            "babel-runtime": "^6.23.0",
            "chalk": "^1.1.3",
            "connect-history-api-fallback": "^1.1.0",
            "css-loader": "^0.25.0",
            "eventsource-polyfill": "^0.9.6",
            "express": "^4.15.3",
            "extract-text-webpack-plugin": "^1.0.1",
            "file-loader": "^0.9.0",
            "function-bind": "^1.0.2",
            "html-webpack-plugin": "^2.8.1",
            "http-proxy-middleware": "^0.17.2",
            "json-loader": "^0.5.4",
            "less": "^2.7.1",
            "less-loader": "^2.2.3",
            "opn": "^4.0.2",
            "ora": "^0.3.0",
            "semver": "^5.3.0",
            "shelljs": "^0.7.4",
            "style-loader": "^0.13.1",
            "url-loader": "^0.5.7",
            "vue-loader": "^10.0.0",
            "vue-style-loader": "^1.0.0",
            "vue-template-compiler": "^2.1.0",
            "webpack": "^1.13.2",
            "webpack-dev-middleware": "^1.8.3",
            "webpack-dev-server": "^1.16.2",
            "webpack-hot-middleware": "^2.12.2",
            "webpack-merge": "^0.14.1"
        },
        "engines": {
            "node": ">= 4.0.0",
            "npm": ">= 3.0.0"
        }
    }
    下载项目的package.json示例
    下载的包 是当前项目的依赖包
            如当前项目依赖 jquery + bootstrap
                npm i jquery --save
                npm i bootstrap --save
                    当前项目的依赖包
                    dependencies:{

                  "bootstrap": "^3.3.7",
                  "jquery": "^3.3.1"

                    }
                 压缩、丑陋化
                    
                 前端三大工具:
                        grant
                        gulp
                        webpack4.0
                 npm run dev
                    
                 npm  i webpack@4.0 --save-dev
                    开发环境下的依赖包
                    devDependencies:{

                  "webpack": "^1.13.2",
                  "webpack-dev-middleware": "^1.8.3",
                  "webpack-dev-server": "^1.16.2",
                  "webpack-hot-middleware": "^2.12.2",
                  "webpack-merge": "^0.14.1"

                    }




  • 相关阅读:
    yii---模型的创建
    yii---控制器的创建
    yii的安装
    windows下安装composer
    wpgcms---列表页数据渲染
    Twig---基本使用
    wpgcms---详情页面数据怎么渲染
    Twig---的使用
    vue---指令怎么写
    vue---设置缩进为4个空格
  • 原文地址:https://www.cnblogs.com/lbzbky/p/11790110.html
Copyright © 2011-2022 走看看