質問

I just created a node_module with a dependency with 'validator'. But when I install it from npm, it doesn't install the 'validator' module in its own node_module directory. I don't understand why, but it's the first time I create my own node module.

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"
  }
}

I also have a .npmignore file with this:

########################
# 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

Should I push the node_modules/ directory into my git repository?

役に立ちましたか?

解決

You should remove your existing package.json and run

npm init

to properly initialise your project. Once that's done, add validator to the dependencies. This should allow npm install to work properly and install your dependencies. Don't commit your node_modules folder.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top