0

I have create a npm package to install "gulp" & "nunjucks" and some other features of gulp. and published it in NPM repository named (package name: xdnunjucks-test).

Now I have created new project and trying to install "xdnunjucks-test" then it is added to my new project but all the dependencies in xdnunjucks-test are not added to new project. command: npm install xdnunjucks-test

-- I should create a custom NPM package to install all dependencies in my new projects. This will helps me to avoid run all the commands in xdnunjucks-test everytime.

single command to run multiple commands.

here are my package.json file content. Published Custom NPM command - package.json:

{
  "name": "xdnunjucks-test",
  "version": "1.0.5",
  "description": "Custom npm command creation",
  "main": "index.js",
  "scripts": {
    "test": "XDNunjucks",
    "start": "npm install gulp",
    "bootstrap-gulp": "npm i bootstrap-gulp",
    "gulp-uglify": "npm install gulp-uglify",
    "gulp-sass": "npm install node-sass gulp-sass",
    "gulp-imagemin": "npm install gulp-imagemin",
    "gulp-minify": "npm install gulp-minify",
    "gulp-livereload": "npm install gulp-livereload",
    "gulp-data": "npm install gulp-data",
    "browser-sync": "npm install browser-sync"
  },
  "keywords": [
    "npm",
    "test"
  ],
  "author": "Anil",
  "license": "ISC",
  "devDependencies": {
    "browser-sync": "^2.26.7",
    "gulp": "^4.0.2",
    "gulp-data": "^1.3.1",
    "gulp-imagemin": "^7.1.0",
    "gulp-livereload": "^4.0.2",
    "gulp-minify": "^3.1.0",
    "gulp-nunjucks-render": "^2.2.3",
    "gulp-sass": "^4.0.2",
    "gulp-uglify": "^3.0.2",
    "node-sass": "^4.13.1"
  },
  "dependencies": {
    "bootstrap-gulp": "^2.2.5"
  }
}

new project package.json:

{
  "name": "n-test-2",
  "version": "1.0.0",
  "description": "",
  "main": "gulpfile.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "xdnunjucks-test": "^1.0.5"
  }
}

After installing the "xdnunjucks-test" command. I didn't get the features of "xdnunjucks-test" in new project.

Please help in in this.

Thank you.

Anilkumar
  • 13
  • 4

1 Answers1

0

All the dependencies in you package xdnunjucks-test is only "bootstrap-gulp" "^2.2.5" all other dependency from devDependency will not be installer in package.

For example if you need to use gulp-uglify in installed package xdnunjucks-test - you should move it to dependency

devDependencies are:

  • installed on npm install on a directory that contains package.json, unless you pass the --production flag (go upvote Gayan Charith's answer).
  • not installed on npm install "$package" on any other directory, unless you give it the --dev option.
  • are not installed transitively.

You can find more about npm dependency on stackoverflow and npm documentation

Andrew
  • 44
  • 3