为什么我们需要使用package.json? [英] Why do we need to use package.json?

查看:202
本文介绍了为什么我们需要使用package.json?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用JavaScript来访问此站点的Web套接字,但是我确实不明白为什么我需要使用 package.json .这是我的package.json文件代码:

I am trying to learn web socket with JavaScript to this site, but I do not understand something that why I need to use package.json. This is my package.json file code:

`{
  "name": "module-name",
  "version": "10.3.1",
  "description": "An example module to illustrate the usage of a package.json",
  "author": "Your Name <you.name@example.org>",
  "contributors": [{
  "name": "Foo Bar",
  "email": "foo.bar@example.com"
}],
  "bin": {
  "module-name": "./bin/module-name"
},
  "scripts": {
    "test": "vows --spec --isolate",
    "start": "node index.js",
    "predeploy": "echo im about to deploy",
    "postdeploy": "echo ive deployed",
    "prepublish": "coffee --bare --compile --output lib/foo src/foo/*.coffee"
  },
  "main": "lib/foo.js",
  "repository": {
  "type": "git",
  "url": "https://github.com/nodejitsu/browsenpm.org"
},
  "bugs": {
  "url": "https://github.com/nodejitsu/browsenpm.org/issues"
},
  "keywords": [
  "nodejitsu",
  "example",
  "browsenpm"
],
  "dependencies": {
    "primus": "*",
    "async": "~0.8.0",
    "express": "4.2.x",
    "winston": "git://github.com/flatiron/winston#master",
    "bigpipe": "bigpipe/pagelet",
    "plates": "https://github.com/flatiron/plates/tarball/master"
  },
  "devDependencies": {
    "vows": "^0.7.0",
    "assume": "<1.0.0 || >=2.3.1 <2.4.5 || >=2.5.2 <3.0.0",
    "pre-commit": "*"
  },
  "preferGlobal": true,
  "private": true,
  "publishConfig": {
  "registry": "https://your-private-hosted-npm.registry.nodejitsu.com"
},
  "subdomain": "foobar",
  "analyze": true,
  "license": "MIT"
}` 

但是我不明白为什么我需要使用它.我试图在Google上找到但找不到有用的东西.还有一件事,如果我创建package.json,那么为什么我需要写依赖项?

But I do not understand why I need to use it. I tried to find on google but can not find something useful. One more thing, if I create package.json then why I need to write dependencies?

推荐答案

您不需要package.json.但是,您很可能会想要它.当您使用node.js制作大型应用程序时,与使用相同的代码相比,使用其他人的代码是最好的解决方案.

You do not NEED package.json. However, you will most likely want it. As you make larger applications using node.js, you will find that using other people's code is the best solution vs. writing the same thing yourself.

npm有很多人们想一遍又一遍地使用的软件包. package.json为人们提供了一种简单的方法来跟踪他们在应用程序中使用的软件包.

npm has lots of packages that people want to use over and over again. package.json provides a simple way for people to keep track of packages they use in their application.

这篇关于为什么我们需要使用package.json?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆