3

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?

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I ust did it. I also updated the main post to show how was my old package.json before npm init.
If the previous package.json was what was causing the problem, you should revert it in the question. This way others with the same problem will recognise it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.