• 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"

                    }




  • 相关阅读:
    macOS 遇到 svnadmin无法使用的情况
    语音识别进化简史:从造技术到建系统
    你是什么垃圾?人工智能面对干垃圾和湿垃圾“有点蒙”
    垃圾分类的事,让机器人做去吧!
    怎样才能叫一只奶牛自愿挤奶?
    第一次,脑机接口可以实时读取人类语言了
    机器人工作原理的超详细解析,生动、形象!
    1900页数学基础:面向CS的线性代数、拓扑、微积分和最优化
    微软Azure AI负责人:OpenAI只在微软云上训练模型
    Velodyne收购高清地图公司 将研发更安全的ADAS系统
  • 原文地址:https://www.cnblogs.com/lbzbky/p/11790110.html
Copyright © 2020-2023  润新知