Git Product home page Git Product logo

install-webpack-plugin's Introduction

npm deps test coverage chat

Install Webpack Plugin

Speed up development by automatically installing & saving dependencies with Webpack.

It is inefficient to Ctrl-C your build script & server just to install a dependency you didn't know you needed until now.

Instead, use require or import how you normally would and installation will happen automatically to install & save missing dependencies while you work!

Installation

$ npm install --save-dev install-webpack-plugin

Usage

In your webpack.config.js:

plugins: [
  new InstallPlugin()
],

This is equivalent to:

plugins: [
  new InstallPlugin({
    dependencies: {
      peer: true,
    },
    packageManager: {
      type: this.getDefaultPackageManager(),
      options: {
        dev: false,
        quiet: false,
      },
    },
    prompt: true,
  });
],

Options

dependencies

Type: Object

Dependencies related options.

peer

Type: Boolean

Default: true

Install missing peer dependencies.

plugins: [
  new InstallPlugin({
    dependencies: {
      peer: true,
    }
  }),
],

packageManager

Type: 'npm' | 'yarn' | 'pnpm' | Object | Function

Package manager to use for installing dependencies.

plugins: [
  new InstallPlugin({
      packageManager: 'yarn'
    },
  }),
],

You can provide a Function to the packageManager to make it dynamic:

plugins: [
  new InstallPlugin({
    packageManager: function(module, path) {
      return [
        "babel-preset-react-hmre",
        "webpack-dev-middleware",
        "webpack-hot-middleware",
      ].indexOf(module) !== -1;
    },
  }),
],

type

Type: 'npm' | 'yarn' | 'pnpm'

Name of package manager to use for installing dependencies.

options

Type: Object

Package manager related options.

arguments

Type: Array

Provide custom arguments to use with package manager.

plugins: [
  new InstallPlugin({
      packageManager: {
        type: 'npm',
        options: {
          arguments: ['--ignore-scripts']
        }
      }
    },
  }),
],

dev

Type: Boolean

Default: false

Install as development dependencies.

plugins: [
  new InstallPlugin({
      packageManager: {
        type: 'npm',
        options: {
          dev: true,
        }
      }
    },
  }),
],

quiet

Type: Boolean

Default: false

Reduce the amount of console logging.

plugins: [
  new InstallPlugin({
      packageManager: {
        type: 'npm',
        options: {
          quiet: true,
        }
      }
    },
  }),
],

prompt

Type: Boolean

Default: true

Show a prompt to confirm installation.

plugins: [
  new InstallPlugin({
      prompt: true,
    },
  }),
],

Demo

install-webpack-plugin demo

Features

  • Works with webpack ^v5.0.0.
  • Auto-installs .babelrc plugins & presets.
  • Supports both ES5 & ES6 Modules. (e.g. require, import)
  • Supports Namespaced packages. (e.g. @cycle/dom)
  • Supports Dot-delimited packages. (e.g. lodash.capitalize)
  • Supports CSS imports. (e.g. @import "~bootstrap")
  • Supports webpack loaders. (e.g. babel-loader, file-loader, etc.)
  • Supports inline webpack loaders. (e.g. require("bundle?lazy!./App")
  • Auto-installs missing peerDependencies. (e.g. @cycle/core will automatically install rx@*)
  • Supports webpack's resolve.alias & resolve.root configuration. (e.g. require("react") can alias to react-lite)

Contributing

Please take a moment to read our contributing guidelines if you haven't yet done so.

CONTRIBUTING

install-webpack-plugin's People

Contributors

anikethsaha avatar anshumanv avatar chenxsan avatar coobaha avatar coryhouse avatar dependabot[bot] avatar ericclemmons avatar greenkeeperio-bot avatar insin avatar jamesgeorge007 avatar jingsam avatar joshwiens avatar jsteunou avatar lcxfs1991 avatar montogeek avatar poeticninja avatar skipjack avatar snitin315 avatar wbeard avatar wizardofhogwarts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

install-webpack-plugin's Issues

webpack-dev-server doesn't find packages right after they're installed

Not sure if it's a problem with my setup (well, it kind of has to be, since in your video it works fine, hah), but when the plugin installs a package automatically (which works very well), the webpack dev server throws an error that the package isn't there. If I ctrl+s the file again without any modification, then it works.

Kind of like if there was a race condition, and webpack tried to recompile too quickly. Any thought? This is on Windows, in case its OS specific (didn't try on OSX yet)

Intermittent failure to resolve module after installation

The only reliable repro I can get is that this happens every single time I attempt to document nwb's --[auto-]install option with some example output:

λ preact run Lightbulb.js --install
Starting Webpack compilation...
Compiled successfully in 4153 ms.

The app is running at http://localhost:3000/
Recompiling...
Installing bootstrap...
Failed to compile with 1 error.

 ERROR  in ./Lightbulb.js
Module not found: Error: Cannot resolve module 'bootstrap/dist/css/bootstrap.css' in C:\Users\Jonny\tmp\preact-play
 @ ./Lightbulb.js 6:0-43

λ preact run Lightbulb.js --install
Starting Webpack compilation...
Compiled successfully in 17268 ms.

The app is running at http://localhost:3000/

Exclude some packages

I think there should be a list of packages to be excluded.

For example, I'm using webpack's resolve alias

alias: {
  src: path.resolve(__dirname, '../src'),
}

so basically I import all my app code starting from src - the plugin tries to install src, which is a problem

Cannot read property 'plugin' of null

npm-install-webpack-plugin stop systematically with this error

TypeError: Cannot read property 'plugin' of null
    at NpmInstallPlugin.apply (/home/alexandre/Project_tests/npm-install-webpack-plugin/example/webpack2/node_modules/npm-install-webpack-plugin/src/plugin.js:50:28)

I am using the example provided in this repository: https://github.com/webpack-contrib/npm-install-webpack-plugin/tree/master/example/webpack2

When running npm run start, dependencies seems to be resolve but not not the loaders

Installing babel-core...
Installing babel-plugin-react-html-attrs...
Installing babel-preset-react...
Installing babel-preset-stage-0...
Installing babel-preset-react-hmre...
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN [email protected] requires a peer of react@^0.14.0 || ^15.0.0 but none was installed.
npm WARN [email protected] requires a peer of react-dom@^0.14.0 || ^15.0.0 but none was installed.
Installing peerDependencies...
Installing react...
Installing react-dom...
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

/home/alexandre/Project_tests/npm-install-webpack-plugin/example/webpack2/node_modules/webpack/bin/webpack.js:315
		throw e;
		^

TypeError: Cannot read property 'plugin' of null
    at NpmInstallPlugin.apply (/home/alexandre/Project_tests/npm-install-webpack-plugin/example/webpack2/node_modules/npm-install-webpack-plugin/src/plugin.js:50:28)
    at Compiler.apply (/home/alexandre/Project_tests/npm-install-webpack-plugin/example/webpack2/node_modules/tapable/lib/Tapable.js:306:16)
    at webpack (/home/alexandre/Project_tests/npm-install-webpack-plugin/example/webpack2/node_modules/webpack/lib/webpack.js:32:19)
    at processOptions (/home/alexandre/Project_tests/npm-install-webpack-plugin/example/webpack2/node_modules/webpack/bin/webpack.js:305:14)
    at Object.<anonymous> (/home/alexandre/Project_tests/npm-install-webpack-plugin/example/webpack2/node_modules/webpack/bin/webpack.js:363:1)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.runMain (module.js:604:10)
    at run (bootstrap_node.js:394:7)
    at startup (bootstrap_node.js:149:9)
    at bootstrap_node.js:509:3

node 6.9.5 (LTS)
linux:

  • NAME="Ubuntu"
  • VERSION="16.04 LTS (Xenial Xerus)"

Transitive dependencies with npm3

Does something special need to be done to ensure an install isn't skipped if npm3 is being used and the user tries to import a module which is in their transitive dependencies?

e.g. if you're using react-router and you want to use qs in your own app, it will be resolved from the version of node_modules npm3 creates, so nothing will be installed or added to package.json

Double-save to Install

The cynics have no problem killing processes, restarting servers, & having a crappy workflow to npm install dependencies, but have a problem with maybe accidentally installing a dependency because they've carelessly typo-d lodsh. 👀

Anyway, I think it'd be legit if:

  1. First save with a missing dependency threw an error (before Webpack got to it!) saying the dependency is missing. Heck, copying the error format could be useful?
  2. The second time saving the file (dunno if plugins will still fire knowing nothing has changed!) would save & install the dep.
Whoa there! `lodash` hasn't been installed yet!
Save your file again to install `lodash` automatically...

Tries to install relative entry in cwd

With webpack config below, where app.js is in process.cwd():

entry:
   [ 'C:\\Users\\Jonny\\AppData\\Roaming\\npm\\node_modules\\nwb\\node_modules\\eventsource-polyfill\\dist\\browserify-eventsource.js',
     'C:\\Users\\Jonny\\AppData\\Roaming\\npm\\node_modules\\nwb\\node_modules\\webpack-hot-middleware\\client.js',
     'app.js' ],

Result:

webpack building...
Installing app.js...
npm WARN package.json [email protected] No description
npm WARN package.json [email protected] No repository field.
npm WARN package.json [email protected] No README data
npm ERR! not a package C:\Users\Jonny\tmp\serve-react\app.js
npm ERR! addLocal Could not install C:\Users\Jonny\tmp\serve-react\app.js
npm ERR! Windows_NT 10.0.10586
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Jonny\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "app.js" "--save"

Works fine if I path.resolve() the entry so it gets an absolute path instead - I'm going to change my own code to do this right now, but thought this was worth reporting.

Working with relative imports using 'resolve'

When working with webpack, we use resolve, as such:

  resolve: {
    // Enable resolving modules relative to these paths
    root: [path.join(__dirname, 'lib')],
  }

Then import files like so:
import state from 'api/state';

The problem is that npm-install-webpack-plugin tries to install the node module called api.

I would suggest only installing files that webpack can't resolve (maybe there's a hook for that?).

Add an option to disable saving to package.json

If #80 was implemented, we could add an option to disable saving newly-installed modules to package.json (and disable checking for it and creating it when it doesn't exist) - the default behaviour is what I want in a project context, but I would like to disable it when prototyping.

repeatedly installs same modules

I installed npm-install-webpack-plugin on these two projects of mine:

Every time I run npm start several modules are installed. Not once but repeatedly. This prevents webpack from building during several minutes.

Here is the output:

PS C:\Users\alex\gs> npm start

> [email protected] start C:\Users\alex\gs
> hjs-dev-server

Installing `webpack-hot-middleware`...
npm WARN install Couldn't install optional dependency: Unsupported
[email protected] C:\Users\alex\gs
└── [email protected]

npm WARN EPACKAGEJSON [email protected] No repository field.
Listening at http://localhost:3000
Installing `file`...
npm WARN install Couldn't install optional dependency: Unsupported
[email protected] C:\Users\alex\gs
└── [email protected]  extraneous

npm WARN EPACKAGEJSON [email protected] No repository field.
Installing `file`...
npm WARN install Couldn't install optional dependency: Unsupported
[email protected] C:\Users\alex\gs
└── [email protected]  extraneous

npm WARN EPACKAGEJSON [email protected] No repository field.
Installing `file`...
npm WARN install Couldn't install optional dependency: Unsupported
[email protected] C:\Users\alex\gs
└── [email protected]  extraneous

npm WARN EPACKAGEJSON [email protected] No repository field.
Installing `react-transform-hmr`...
npm WARN install Couldn't install optional dependency: Unsupported
[email protected] C:\Users\alex\gs
└── [email protected]

npm WARN EPACKAGEJSON [email protected] No repository field.
Installing `file`...
npm WARN install Couldn't install optional dependency: Unsupported
[email protected] C:\Users\alex\gs
└── [email protected]  extraneous

npm WARN EPACKAGEJSON [email protected] No repository field.
Installing `file`...
npm WARN install Couldn't install optional dependency: Unsupported
[email protected] C:\Users\alex\gs
└── [email protected]  extraneous

npm WARN EPACKAGEJSON [email protected] No repository field.
Installing `file`...
npm WARN install Couldn't install optional dependency: Unsupported
[email protected] C:\Users\alex\gs
└── [email protected]  extraneous

npm WARN EPACKAGEJSON [email protected] No repository field.
Installing `file`...
npm WARN install Couldn't install optional dependency: Unsupported
[email protected] C:\Users\alex\gs
└── [email protected]  extraneous

npm WARN EPACKAGEJSON [email protected] No repository field.
Installing `react-transform-hmr`...
npm WARN install Couldn't install optional dependency: Unsupported
[email protected] C:\Users\alex\gs
└── [email protected]

npm WARN EPACKAGEJSON [email protected] No repository field.
Installing `react-transform-hmr`...
npm WARN install Couldn't install optional dependency: Unsupported
[email protected] C:\Users\alex\gs
└── [email protected]

npm WARN EPACKAGEJSON [email protected] No repository field.
Installing `react-transform-hmr`...
npm WARN install Couldn't install optional dependency: Unsupported
[email protected] C:\Users\alex\gs
└── [email protected]

npm WARN EPACKAGEJSON [email protected] No repository field.
Installing `react-transform-hmr`...
npm WARN install Couldn't install optional dependency: Unsupported
[email protected] C:\Users\alex\gs
└── [email protected]

npm WARN EPACKAGEJSON [email protected] No repository field.
Installing `react-transform-hmr`...
npm WARN install Couldn't install optional dependency: Unsupported
[email protected] C:\Users\alex\gs
└── [email protected]

npm WARN EPACKAGEJSON [email protected] No repository field.
Installing `react-transform-hmr`...
npm WARN install Couldn't install optional dependency: Unsupported
[email protected] C:\Users\alex\gs
└── [email protected]

npm WARN EPACKAGEJSON [email protected] No repository field.
webpack built dd8ccb8a57a7a8d935d3 in 147687ms
webpack building...
webpack built dd8ccb8a57a7a8d935d3 in 133ms

Expose installer

This would be useful for @terse/webpack's own Plugin class, so that it can auto-install stuff that's missing.

Forgetting to prefix local path with ./ leads to unexpected installation

I wrote a simple module, that is located injs/admin. Without thinking about it much, I wrote

import colourizeColourselects from 'js/admin/colourizeColourselects';

and was a bit shocked to see "Installing js..." appear in my terminal, as I certainly didn't want to install anything.

Since anyone can upload basically anything to npm, and npm provides hooks such as postinstall, this is potentially dangerous. Could there be an additional check, just to see if the user actually meant to import a local module instead of blindly? Is js/admin/colourizeColourselects even a valid name for a package?

Prefix for own logging

What do you think of prefixing the plugin's own logging with "[NpmInstallPlugin] " or similar so it's clear where it's coming from?

cannot resolve module

I'm getting an issue where once the module has been installed, and the package.json updated, webpack then tries to do its thing, but cannot resolve the module, its looking in my app's source folder rather than the node_modules folder in the root of the project. As soon as i stop and restart webpack its fine.

Any ideas?

jestpack-loader issue

Hello,

added jestpack into my build and it for some reason trying to install by name which doesn't exists.

Jestpack is in npm repository as jestpack and not as jestpack-loader which is trying to be installed.

Installing jestpack-loader...
npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/Cellar/node/6.3.1/bin/node" "/usr/local/bin/npm" "install" "jestpack-loader" "--save"
npm ERR! node v6.3.1
npm ERR! npm  v3.10.3
npm ERR! code E404

npm ERR! 404 Registry returned 404 for GET on https://registry.npmjs.org/jestpack-loader
npm ERR! 404
npm ERR! 404  'jestpack-loader' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/pjuna/Development/javascript/redux/pyxis_on_redux/npm-debug.log

Is there any way of ignoring specific packages? I see this solution as quick possible override.

Thank you

Not work at [email protected]

compiler.resolvers.normal.plugin("module", this.resolveModule.bind(this))

should be

 compiler.plugin('compilation', (compilation) => {
  compilation.resolvers.normal.plugin("module", this.resolveModule.bind(this))
})

this works for me now.

I don't know whether the API will change again when the the official version webpack@2 is released.

Feature request: support for webpack resolve.alias and resolve.root

I saw that this was mentioned in #13 (comment) and that it is currently being worked on (:clap:), but thought it might make sense to have it as it’s own issue for other people who have discovered the problem and want to know more about it. But please feel free to close this issue. Also, if there are any parts of the work to support resolve.root / resolve.alias that others could help with, I’d love to contribute!

On to the issue description:


If you set up a webpack alias that you want to be able to use in your imports / requires, those aliases will be interpreted as referring to an external npm package, and this plugin will try to install it. For example, if you define an svg alias to point to a folder of svg files, and then want to require one of those files like require('svg/icon.svg'), you will have npm’s svg package installed into your repo.

installPeers Option

peerDependencies can be installed automatically, but isn't 100% what's desired.

For example, if I alias react to react-lite, NPM is entirely unaware that I've satisfied my React dependency.

I think defaulting this to true is useful, but should be an explicit option.

Issue with @angularclass/hmr-loader

Hello,

I use the @angularclass/hmr-loader npm webpack plugin, but it tries to install a lib named @angularclass-loader, looks like it doesn't handle the / well.

From my webpack config:

loaders: [
            // Support for .ts files.
            {
                test: /\.ts$/,
                loaders: ['awesome-typescript', 'angular2-template', '@angularclass/hmr-loader'],
                exclude: [/\.(spec|e2e)\.ts$/]
            }

Endless loop when installing the module alert

In my Vue.js source code, I have this line

alert = require('alert')

This in turn triggers npm-install-plugin to install alert and alert.js. The problem is the installation keeps repeating endlessly, even though both modules have been installed in node_modules/ and added to package.json

Video of npm install webpack

npm-install-plugin

Strip webpack directives before running npm install

Thanks for a great loader!

With Wepack you can specify loaders in the require/import statement like this:

import logotype from '!!raw!image-webpack!./logo.svg';

Which this loader will pick up and try to install it. And that install will fail and print a bunch or errors in the console.
Perhaps check if the import/require contains ! and then ignore it? Or make it possible to provide a RegEx for import/require statements that this loader should ignore.

Warning for "spawnSync npm ENOENT"

Hi!
Dependencies hasn't installed when I set process.env.NODE_ENV to "development" on Mac OS.

Installing underscore...
Installing underscore...
Installing underscore...
Installing underscore...
Hash: b6a12f64cf3c10156334
Version: webpack 3.5.5
Time: 5328ms
                               Asset       Size  Chunks                    Chunk Names
780cd4e05755d6fef36478d58314ef65.png  302 bytes          [emitted]         
3ec2904732c72b301eff663c0c54da80.png  414 bytes          [emitted]         
744113230af69bc819fac37c2346c46e.png  426 bytes          [emitted]  

After I written "console.log(output.error);" in src/Installer.js, the terminal displays as follows.

Installing underscore...
{ Error: spawnSync npm ENOENT
    at exports._errnoException (util.js:1020:11)
    at spawnSync (child_process.js:450:20)
    at Function.spawnSync [as sync] (/Users/alfred/Desktop/learning/plutarch/node_modules/npm-install-webpack-plugin/node_modules/cross-spawn/index.js:46:14)
    at Object.install (/Users/alfred/Desktop/learning/plutarch/node_modules/npm-install-webpack-plugin/src/installer.js:159:22)
    at NpmInstallPlugin.install (/Users/alfred/Desktop/learning/plutarch/node_modules/npm-install-webpack-plugin/src/plugin.js:73:15)
    at NpmInstallPlugin.<anonymous> (/Users/alfred/Desktop/learning/plutarch/node_modules/npm-install-webpack-plugin/src/plugin.js:193:12)
    at onError (/Users/alfred/Desktop/learning/plutarch/node_modules/enhanced-resolve/lib/Resolver.js:65:10)
    at loggingCallbackWrapper (/Users/alfred/Desktop/learning/plutarch/node_modules/enhanced-resolve/lib/createInnerCallback.js:31:19)
    at runAfter (/Users/alfred/Desktop/learning/plutarch/node_modules/enhanced-resolve/lib/Resolver.js:158:4)
    at innerCallback (/Users/alfred/Desktop/learning/plutarch/node_modules/enhanced-resolve/lib/Resolver.js:146:3)      

Will it be better to print this error?

Trying to install webpack loaders with `-loader` in it

I'm seeing lots of Installing [XXX]-loader-loader... attempts that lead to 404.

I use XXX-loader (explicit) notation in my webpack config since the previous version tried to install loaders with -loader suffix. I think this is a regression since it has been working as expected before.

Check whether module is actually installed

Hi,

I use your great webpack plugin in my prototyping tool — Aik. And it works pretty well. And covers most of use cases except one:

If I have package.json but haven't yet installed node modules npm-install-webpack-plugin thinks that they are installed because of this check:

https://github.com/ericclemmons/npm-install-webpack-plugin/blob/master/src/installer.js#L42-L44

What do you think about checking on file system whether directory exists or not instead of checking in package.json?

I can send a pull request if you think it's a good idea :)

issue with babel-root-import in .babelrc plugins

that's my .babelrc

{
  "presets": ["es2015", "react"],
  "plugins": [
    "babel-root-import"
  ],
  "env": {
    "development": {
      "presets": ["react-hmre"]
    }
  }
}

and this is what I get when I run the server:

❯ npm run server:dev

> [email protected] server:dev /Users/cla/Git Projects/bitbucket-foxhound87/we-must-react-ep-03
> NODE_ENV=development node server.js

Installing babel-plugin-babel-root-import...
npm ERR! Darwin 15.5.0
npm ERR! argv "/Users/cla/.nvm/versions/node/v6.2.2/bin/node" "/Users/cla/.nvm/versions/node/v6.2.2/bin/npm" "install" "babel-plugin-babel-root-import" "--save"
npm ERR! node v6.2.2
npm ERR! npm  v3.9.5
npm ERR! code E404

npm ERR! 404 Registry returned 404 for GET on https://registry.npmjs.org/babel-plugin-babel-root-import
npm ERR! 404 
npm ERR! 404  'babel-plugin-babel-root-import' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

It's trying to install a npm package that doesn't exist: babel-plugin-babel-root-import

webpack-defaults upgrade

Addition of webpack-defaults & associated refactoring as a part of the next Major release

Issue exists for status tracking across the organization.

Please do not close

typosquatting

Can you add features to guard against typosquatting? E.g. require confirmation for packages with under a certain threshold of recent downloads.

`stylus` module is missing when used with `stylus-loader`

It seems that neither stylus nor stylus-loader are installed automatically when running webpack with

// webpack.config.js
...
    loaders: [
      {
        test: /\.styl$/, 
        loaders: ['style', 'css', 'stylus']
      }
    ]
...

I had to install both modules manually to make it work.

Can't resolve 'stylus-loader'

I have alread add stylus-loader config to webpack. When I require a stylus file, it successfully installed the dependencies, but it comes up with the following error:

image

When I restart the cmd, it works correctly.

Modules installed on parent are not seen

Hey guys! Great tool thanks!

Unfortunately I have a breaking issue, that some of my development modules are defined on the parent package.json, and the tool started to install them in my child module assuming they were not installed.

I didn't had the chance to check how it works, but using require.resolve(module) shouldn't fix this?

Thanks!!!!

Allow save/saveDev/saveExact behavior to be customized based on context

It would be good if there were some kind of hooks in place that would allow you to decide what kind of save to apply given a package within some location.

The reason for this is that I prefer to keep strict separation between dependencies and devDependencies. For example all ./app dependencies would go to the former category whereas the rest would go to the latter.

It would be enough for me if there was a callback that received the context where an import was detected. I could then return the type of save based on that.

What do you think? If you are busy, I can try to craft a PR. Apart from this, the plugin works very well.

Yarn

It's awesome. Let's support it.

I wish I could rename to auto-install-webpack-plugin, but it's taken & competitive.

I mean, I could do yarn-install-webpack-plugin (alias?), but that seems extreme.

What'd also make it legit would be to auto-install yarn if that's how deps would be managed. 😱

I just don't know what to call the option...

new NpmInstallWebpackPlugin({
  ["client" || "installer" || "script" || "exec" || "bin"]: "yarn add",
  ...
});

I would like to opt for something like yarn: true for restricting the API, so that I don't have to support possible script combination (e.g. $PATH=~/.bin pnpm install --save-dev or something)...

Seems to add extra packages to package.json

Super cool idea, by the way. But I'm trying it out and it seems like it's adding the dependencies of my dependencies to package.json. For instance, cheerio is a dependency of enzyme, and I'm using enzyme in my app. But npm-install-webpack-plugin installed cheerio into my package.json even though I'm not relying on it directly.

Running webpack after adding this plugin leads to endless loop

After I installed this plugin and added it to my webpack.config.js:

plugins:   [
        new NpmInstallPlugin(),
]

it tries to reinstall webpack over and over and doesn't stop:

C:\sites\YDR\branches\refactoring\development>webpack
Installing babel-loader...
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm WARN [email protected] requires a peer of webpack@>=1.3.0 <3 but none was installed.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
Installing peerDependencies...
Installing [email protected]...
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm WARN [email protected] requires a peer of webpack@>=1.3.0 <3 but none was installed.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
Installing peerDependencies...
Installing [email protected]...
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm WARN [email protected] requires a peer of webpack@>=1.3.0 <3 but none was installed.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
(....and it goes on and on....)

I assume it's because I'm including webpack at the beginning of my config?

var webpack = require('webpack');
var autoprefixer = require('autoprefixer');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var NpmInstallPlugin = require('npm-install-webpack-plugin');

Installs loaders that are already installed in sub-module

Thank you for producing this awesome module! 👍 😸

I use a wrapper around Webpack rather than Webpack directly. That wrapper contains css-loader, style-loader, babel-loader etc. I've also added npm-install-webpack-plugin to it. When I build an app with this setup, it installs each of the loaders it comes across even though they're already available in the wrapper. This results in superfluous loaders in my app that are already taken care of by the wrapper.

I imagine that this can be taken care of by adding locations npm-install-webpack-plugin can resolve relative to. If it resolved in the location it was installed (or allowed me to blacklist certain modules or allowed me to skip loaders) it would solve this issue.

Any thoughts?

Tries to install html-webpack-plugin-loader if ^2.21.0

If html-webpack-plugin ^2.21.0 is installed (tested with 2.26.0), npm-install-webpack-plugin tries to install it as a loader. Interestingly 2.21.0 works just fine. A release after that broke the behavior as it gets detected improperly.

To make this easier to debug, I set up a repository. npm install and npm start to get

Installing html-webpack-plugin-loader...
npm ERR! Darwin 16.3.0
npm ERR! argv "/usr/local/Cellar/node6-lts/6.9.1/bin/node" "/usr/local/bin/npm" "install" "html-webpack-plugin-loader" "--save"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! code E404

npm ERR! 404 Registry returned 404 for GET on https://registry.npmjs.org/html-webpack-plugin-loader
npm ERR! 404
npm ERR! 404  'html-webpack-plugin-loader' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.

Don't install peerDependencies which can be resolved by Webpack

If peerDependencies were handled like any other normal module the plugin tries to install and Webpack was able to resolve the package name, they wouldn't be installed.

e.g. when you're using compatibility layers like preact-compat or inferno-compat, they're aliased to 'react', so you don't want the real React to be installed if you import a React component which has React as a peerDependency.

Plugin using incorrect version numbers to package.json

I use npm-install-webpack-plugin with the .npmrc and it installs all my modules, generating this package.json.

When I clone the repo and npm install, I am getting a lot of issues that look like:

npm i
npm WARN deprecated [email protected]: Babel's CLI commands have been moved from the babel package to the babel-cli package
npm ERR! Linux 4.4.0-31-generic
npm ERR! argv "/home/vamsi/.nvm/v6.2.0/bin/node" "/home/vamsi/.nvm/v6.2.0/bin/npm" "i"
npm ERR! node v6.2.0
npm ERR! npm  v3.8.9

npm ERR! No compatible version found: babel-eslint@^7.1.0
npm ERR! Valid install targets:
npm ERR! 6.0.4, 6.0.3, 6.0.2, 6.0.1, 6.0.0, 6.0.0-beta.6, 6.0.0-beta.5, 6.0.0-beta.4, 6.0.0-beta.3, 6.0.0-beta.2, 6.0.0-beta.1, 5.0.4, 5.0.3, 5.0.2, 5.0.1, 5.0.0, 5.0.0-beta9, 5.0.0-beta8, 5.0.0-beta7, 5.0.0-beta6, 5.0.0-beta5, 5.0.0-beta4, 5.0.0-beta3, 5.0.0-beta2, 5.0.0-beta10, 5.0.0-beta1, 4.1.8, 4.1.7, 4.1.6, 4.1.5, 4.1.4, 4.1.3, 4.1.2, 4.1.1, 4.1.0, 4.0.10, 4.0.9, 4.0.8, 4.0.7, 4.0.6, 4.0.5, 4.0.4, 4.0.3, 4.0.2, 4.0.1, 4.0.0, 3.1.30, 3.1.29, 3.1.28, 3.1.27, 3.1.26, 3.1.25, 3.1.24, 3.1.23, 3.1.22, 3.1.21, 3.1.20, 3.1.19, 3.1.18, 3.1.17, 3.1.16, 3.1.15, 3.1.14, 3.1.13, 3.1.12, 3.1.11, 3.1.10, 3.1.9, 3.1.8, 3.1.7, 3.1.6, 3.1.5, 3.1.4, 3.1.3, 3.1.1, 3.1.0, 3.0.1, 3.0.0, 2.0.2, 2.0.0, 1.0.14, 1.0.13, 1.0.12, 1.0.11, 1.0.10, 1.0.9, 1.0.8, 1.0.7, 1.0.6, 1.0.4, 1.0.3, 1.0.2, 1.0.1, 1.0.0
npm ERR! 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.