从npm安装node_module但它没有安装自己的node_modules - package.json

Vad*_*est 3 dependencies node.js node-modules

我刚创建了一个node_module,其依赖关系为'validator'.但是当我从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"
  }
}
Run Code Online (Sandbox Code Playgroud)

我还有一个.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
Run Code Online (Sandbox Code Playgroud)

我应该将node_modules /目录推入我的git存储库吗?

qub*_*yte 5

您应该删除现有的package.json并运行

npm init
Run Code Online (Sandbox Code Playgroud)

正确初始化您的项目.完成后,将验证器添加到依赖项中.这应该允许npm install正常工作并安装您的依赖项.不要提交您的node_modules文件夹.