Describe the bug
Running npm install in a project depending on webpack-cli fails with lerna: command not found.
To Reproduce
mkdir test && cd test
npm init
npm add webpack/webpack-cli
What is the current behavior?
[gwylim@gwylim test]$ npm install
> [email protected] postinstall /home/gwylim/test/node_modules/webpack-cli
> lerna bootstrap
sh: lerna: command not found
npm WARN [email protected] requires a peer of webpack@^4.x.x but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No description
npm WARN [email protected] No repository field.
npm WARN [email protected] No license field.
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! [email protected] postinstall: `lerna bootstrap`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/gwylim/.npm/_logs/2018-10-05T19_24_36_020Z-debug.log
Additional context
This seems to be related to https://github.com/webpack/webpack-cli/commit/415084913204d206579a5fc7d5dbc2f88555da31, since npm install is no longer run before lerna bootstrap. It works as expected if that commit is reverted.
My machine is running Arch Linux with npm version 5.6.0. This only seems to occur on linux from what we've observed.
Can you try to do npm install without the prod flag?
Yes, that works when running npm install in webpack-cli, but the main bug here is that adding webpack-cli as a dependency of another package doesn't work. When you run npm add webpack/webpack-cli in another package, it doesn't install the dev dependencies of webpack-cli (such as lerna).
that's intended. When adding the CLI it should be used to compile webpack, not developing it locally
Sorry, maybe I haven't explained it well or I've misunderstood something. If I create a minimal npm package with the following package.json, it results in the above error when running npm install. Is it a bug or expected behavior? If it's expected, then what's wrong with my package.json?:
{
"name": "test",
"version": "1.0.0",
"devDependencies": {
"webpack-cli": "webpack/webpack-cli"
}
}
If you want to contribue to webpack-cli:
$ git clone https://github.com/webpack/webpack-cli
$ cd webpack-cli
$ npm install / npm run bootstrap
$ npm test
If you want to develop applications using webpack-cli:
$ yarn add webpack-cli / npm install --save webpack-cli
$ webpack-cli
Ok, I've edited the description to hopefully be more clear about the actual issue.
I see that you are linking the cli internally. But if you don't run the npm install inside the cli project, it won't find any package. In fact lerna is not installed hence you get that error.
We could improve the documentation
@gwylim did it solve your issue?
Closing as inactive until there鈥檚 any objections