神经网络游戏场07:package.json管理項目

初始化 package.json

# 执行npm  init ,初始化 package.json,-y表示接受默认值
npm  init -y

项目的package.json

{
  "name": "deep-playground-prototype",# 名称和版本共同构成一个标识符
  "version": "2016.3.10",# 发布时使用
  "description": "", # 描述
  "private": true,# 如果 "private": true 在 package.json 中设置,则 npm 将拒绝发布它。
  "scripts": {
    "clean": "rimraf dist",
    "start": "npm run serve-watch",
    "prep": "copyfiles analytics.js dist && concat node_modules/material-design-lite/material.min.js node_modules/seedrandom/seedrandom.min.js > dist/lib.js",
    "build-css": "concat node_modules/material-design-lite/material.min.css styles.css > dist/bundle.css",
    "watch-css": "concat node_modules/material-design-lite/material.min.css styles.css -o dist/bundle.css",
    "build-html": "copyfiles index.html dist",
    "watch-html": "concat index.html -o dist/index.html",
    "build-js": "browserify src/playground.ts -p [tsify] | uglifyjs -c > dist/bundle.js",
    "watch-js": "watchify src/playground.ts -p [tsify] -v --debug -o dist/bundle.js",
    "build": "npm run prep && npm run build-js && npm run build-css && npm run build-html",
    "watch": "npm run prep && concurrently \"npm run watch-js\" \"npm run watch-css\" \"npm run watch-html\"",
    "serve": "npx serve dist/",
    "serve-watch": "concurrently \"npx serve dist/\" \"npm run watch\""
  },
  "devDependencies": {
    "@types/d3": "^3.5.34",
    "concat": "^1.0.3",
    "concurrently": "3.1.0",
    "copyfiles": "1.0.0",
    "rimraf": "2.5.4",
    "serve": "^11.3.0",
    "tsify": "^4.0.0",
    "typescript": "^2.9",
    "uglify-js": "^2.8.29",
    "watchify": "^4.0.0"
  },
  "dependencies": {
    "d3": "^3.5.16",
    "material-design-lite": "^1.3.0",
    "seedrandom": "^2.4.3"
  }
}

开发依赖 devDependencies ,运行依赖 dependencies

npm i -D
参数解释
P, –save-prod包将出现在您的中 dependencies,默认设置
D, –save-dev包在devDependencies
O, –save-optional包在 optionalDependencies
no-save防止保存到 dependencies

scripts:

        根据scripts里的配置,我们可以运行以下代码:

   npm run  clean
   npm run  start
   npm run  prep
   npm run  serve

        在一开始的项目构建里一共运行了三句代码,其中有两个是与scripts有关的:

npm i               # 安装依赖
npm run build       # scripts中的build
npm run serve       # scripts中的serve

参考与更多

npm Docs
中文译

package-lock.json
# webpack 项目管理
cnpm  i  -D webpack  webpack-cli   typescript  ts-loader
or
npm i -D webpack  webpack-cli   typescript  ts-loader
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值