1. Choix
Si vous git et utilisateur GitHub:
generate-package
plus simplement que npm init
.
autre
et / ou vous n'aimez pas le package.json
modèle, qui génère un package ou npm init
génère:
vous pouvez générer votre propre modèle via des applications d'échafaudage comme générer , naviguer ou yeoman .
2. Pertinence
Cette réponse est pertinente pour mars 2018. À l'avenir, les données de cette réponse pourraient être obsolètes.
L'auteur de cette réponse a personnellement utilisé generate-package en mars 2018.
3. Limitations
Vous devez utiliser git et GitHub pour utiliser generate-package.
4. Démonstration
Par exemple, je crée un dossier vide sasha-npm-init-vs-generate-package
.
4.1. générer-package
Commander:
D:\SashaDemoRepositories\sasha-npm-init-vs-generate-package>gen package
[16:58:52] starting generate
[16:59:01] √ running tasks: [ 'package' ]
[16:59:04] starting package
? Project description? generate-package demo
? Author's name? Sasha Chernykh
? Author's URL? https://vk.com/hair_in_the_wind
[17:00:19] finished package √ 1m
package.json
:
{
"name": "sasha-npm-init-vs-generate-package",
"description": "generate-package demo",
"version": "0.1.0",
"homepage": "https://github.com/Kristinita/sasha-npm-init-vs-generate-package",
"author": "Sasha Chernykh (https://vk.com/hair_in_the_wind)",
"repository": "Kristinita/sasha-npm-init-vs-generate-package",
"bugs": {
"url": "https://github.com/Kristinita/sasha-npm-init-vs-generate-package/issues"
},
"license": "MIT",
"engines": {
"node": ">=4"
},
"scripts": {
"test": "mocha"
},
"keywords": [
"generate",
"init",
"npm",
"package",
"sasha",
"vs"
]
}
4.2. npm init
D:\SashaDemoRepositories\sasha-npm-init-vs-generate-package>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 json` 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: (sasha-npm-init-vs-generate-package)
version: (1.0.0) 0.1.0
description: npm init demo
entry point: (index.js)
test command: mocha
git repository: https://github.com/Kristinita/sasha-npm-init-vs-generate-package
keywords: generate, package, npm, package, sasha, vs
author: Sasha Chernykh
license: (ISC) MIT
About to write to D:\SashaDemoRepositories\sasha-npm-init-vs-generate-package\package.json:
{
"name": "sasha-npm-init-vs-generate-package",
"version": "0.1.0",
"description": "npm init demo",
"main": "index.js",
"scripts": {
"test": "mocha"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Kristinita/sasha-npm-init-vs-generate-package.git"
},
"keywords": [
"generate",
"package",
"npm",
"package",
"sasha",
"vs"
],
"author": "Sasha Chernykh",
"license": "MIT",
"bugs": {
"url": "https://github.com/Kristinita/sasha-npm-init-vs-generate-package/issues"
},
"homepage": "https://github.com/Kristinita/sasha-npm-init-vs-generate-package#readme"
}
Is this ok? (yes) y
{
"name": "sasha-npm-init-vs-generate-package",
"version": "0.1.0",
"description": "npm init demo",
"main": "index.js",
"scripts": {
"test": "mocha"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Kristinita/sasha-npm-init-vs-generate-package.git"
},
"keywords": [
"generate",
"package",
"npm",
"package",
"sasha",
"vs"
],
"author": "Sasha Chernykh",
"license": "MIT",
"bugs": {
"url": "https://github.com/Kristinita/sasha-npm-init-vs-generate-package/issues"
},
"homepage": "https://github.com/Kristinita/sasha-npm-init-vs-generate-package#readme"
}
Je pense que, generate-package
plus simplement, cela npm init
.
5. Personnalisation
Cela crée votre propre package.json
modèle, voir des exemples de génération et yeoman .
npm link