我刚刚创建了一个带有'validator'依赖项的node_module。 但是当我从npm安装它时,它不会在自己的node_module目录中安装'validator'模块。我不明白为什么,但这是我第一次创建自己的节点模块。
的package.json:
{
"name": "validator-extended",
"description": "String validation and sanitization based on validator.js",
"version": "1.1.0",
"homepage": "https://github.com/Ayolan/validator-extended",
"keywords": [
"validator",
"validation",
"validate",
"sanitization",
"sanitize",
"sanitisation",
"sanitise",
"assert",
"extend",
"extended"
],
"author": "Vadorequest <https://github.com/Vadorequest>",
"main": "app.js",
"bugs": {
"url": "https://github.com/Ayolan/validator-extended/issues"
},
"repository": {
"type": "git",
"url": "https://github.com/Ayolan/validator-extended.git"
},
"engines": {
"node": ">= 0.8"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/Ayolan/validator-extended/raw/master/LICENSE"
}
],
"dependencies": {
"validator": "~3.1"
}
}
我还有一个.npmignore文件:
########################
# node.js / npm
########################
lib-cov
*.seed
*.log
*.csv
*.dat
*.out
*.pid
*.gz
pids
logs
results
node_modules
npm-debug.log
########################
# misc / editors
########################
*~
*#
.DS_STORE
.netbeans
nbproject
.idea
我应该将node_modules /目录推送到我的git存储库吗?
答案 0 :(得分:5)
您应该删除现有的package.json
并运行
npm init
正确初始化您的项目。完成后,将验证器添加到依赖项中。这应该允许npm install
正常工作并安装您的依赖项。不要提交您的node_modules
文件夹。