How to move from Bower to Npm using main-bower-files?

3.2k views Asked by At

As bower slowly 'shuts down' I am finding it very difficult to migrate from bower to npm. I managed to get the DEV packages downloaded but I cannot seem to figure out how to use equivalent to 'main-bower-files' for npm. I found something similar 'main-npm-files' but there is no way to use the "override" method, similar to how bower uses, to point which files should be copied.

Can someone please guide me on how I can do this? If you need me to paste my package.json here let me know.

1

There are 1 answers

2
Brad Bamford On BEST ANSWER

I believe npmfiles might be what you are looking for (also on github).

Says it was heavily inspired by main-bower-files.

var mainNPMFiles = require('npmfiles');

var files = mainNPMFiles([options]);`

See that [options] tag above, that's where you can includes options to override which files are the main files in a package (exactly like main-bower-files).

{
  "name": "your-package-name",
  "dependencies": {
    "NPM-PACKAGE": "*"
  },
  "overrides": {
    "NPM-PACKAGE": {
      "main": [
        // override the main files or even ignore the package
      ]
    }
  }
}

It should require very little change in your gulpfile, since you're just replacing main-bower-files with main-npm-files.

gulp.task('TASKNAME', function() {
    return gulp.src(mainNPMFiles())
        .pipe(/* what you want to do with the files */)
});