install-webpack-plugin icon indicating copy to clipboard operation
install-webpack-plugin copied to clipboard

Cannot read property 'plugin' of null

Open xNok opened this issue 9 years ago • 18 comments

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

xNok avatar Feb 05 '17 23:02 xNok

me too!

zhao33055 avatar Feb 06 '17 08:02 zhao33055

This should be fixed in master (8ba2ad7) - we just need to cut a release.

insin avatar Feb 06 '17 08:02 insin

it is also doesn't work in webpack2.2.0

zhao33055 avatar Feb 06 '17 10:02 zhao33055

@IZHQT if you look at the fix that @insin mentioned you'll see that he updated webpack to v2.2.0 in it. @insin any idea when the next release will be cut? thanks!

mbnata avatar Feb 06 '17 17:02 mbnata

@insin is there any idea about next release resolving this issue?

xiongchengqing avatar Feb 17 '17 06:02 xiongchengqing

Getting same error in webpack 2.2.1

flexzero avatar Mar 03 '17 06:03 flexzero

well until they push a release. this works for me =>

npm install webpack-contrib/npm-install-webpack-plugin --save-dev

david-whitlark avatar Mar 07 '17 17:03 david-whitlark

  • __ - same

Jorybraun avatar Mar 28 '17 02:03 Jorybraun

hi there. Wondering when the latest fix will be published in npm platform.

lcxfs1991 avatar Apr 09 '17 14:04 lcxfs1991

@ericclemmons could you publish a release pretty please? ;)

JSteunou avatar May 03 '17 13:05 JSteunou

me too

anztrax avatar May 04 '17 12:05 anztrax

same

digitaldeus avatar May 04 '17 18:05 digitaldeus

same here, new release is highly needed

johadi avatar May 08 '17 09:05 johadi

I have the same problem

Afelua avatar May 08 '17 22:05 Afelua

@david-whitlark : Thanks for your solution. It works for me on ubuntu but I am wondring how did you figured out this solution ?

eblonvia avatar May 27 '17 21:05 eblonvia

@eblonvia I realized that the fix had been committed to the repo, but had not been pushed to npm, so by telling npm to install directly from the repo instead of npm allowed me to use the updated code

david-whitlark avatar May 27 '17 23:05 david-whitlark

I've published npm-install-webpack2-plugin to npm in the meantime (which is built from b21bd32) as I need a non-scoped (don't ask) Webpack 2 compatible version.

These are the draft release notes I had ready for the next release:

  • Added a quiet option - enabling it will silence npm install output.
  • Check if modules are resolvable from the current working directory instead of checking dependencies and devDependencies in package.json .
    • package.json is now optional - the plugin will no longer create it if it doesn't exist.
    • If package.json exists, the plugin will --save newly-installed dependencies to it as usual.
  • Allow Webpack to attempt to resolve loaders first, as module.resolveLoaders configuration may enable resolving of loaders which aren't resolvable from the current working directory.
  • Added support for Babel presets specified as a [preset, options] array.
  • Added compatibility for Webpack 2 creating resolvers later in the process.

insin avatar May 27 '17 23:05 insin

Staled and fixed in master

alexander-akait avatar May 27 '21 19:05 alexander-akait