Lerna 没有启动 webpack

Lerna doesn't start webpack

我的根目录中有一个 webpack.config.js(在包含 packages*.json 文件的目录之外),当我启动 lerna run build 时出现此错误:

**ERROR OUTPUT**
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'build' ]
2 info using npm@6.7.0
3 info using node@v11.13.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle access-ninja@1.0.0~prebuild: access-ninja@1.0.0
6 info lifecycle access-ninja@1.0.0~build: access-ninja@1.0.0
7 verbose lifecycle access-ninja@1.0.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle access-ninja@1.0.0~build: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/user/dev/development/6.3_sources/portal-ui/react/packages/access-ninja/node_modules/.bin:/home/user/dev/development/6.3_sources/portal-ui/react/packages/access-ninja/node_modules/.bin:/home/user/dev/development/6.3_sources/portal-ui/react/packages/node_modules/.bin:/home/user/dev/development/6.3_sources/portal-ui/react/node_modules/.bin:/home/user/dev/development/6.3_sources/portal-ui/node_modules/.bin:/home/user/dev/development/6.3_sources/node_modules/.bin:/home/user/dev/development/node_modules/.bin:/home/user/dev/node_modules/.bin:/home/user/node_modules/.bin:/home/node_modules/.bin:/node_modules/.bin:/usr/bin:/home/user/bin/Sencha/Cmd:/home/user/bin:/home/user/.local/bin:/opt/maven-3.5.4/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle access-ninja@1.0.0~build: CWD: /home/user/dev/development/6.3_sources/portal-ui/react/packages/access-ninja
10 silly lifecycle access-ninja@1.0.0~build: Args: [ '-c', 'webpack --progress --mode development' ]
11 silly lifecycle access-ninja@1.0.0~build: Returned: code: 1  signal: null
12 info lifecycle access-ninja@1.0.0~build: Failed to exec build script
13 verbose stack Error: access-ninja@1.0.0 build: `webpack --progress --mode development`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:193:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:193:13)
13 verbose stack     at maybeClose (internal/child_process.js:1001:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:266:5)
14 verbose pkgid access-ninja@1.0.0
15 verbose cwd /home/user/dev/development/6.3_sources/portal-ui/react/packages/access-ninja
16 verbose Linux 4.18.0-16-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "build"
18 verbose node v11.13.0
19 verbose npm  v6.7.0
20 error code ELIFECYCLE
21 error errno 1
22 error access-ninja@1.0.0 build: `webpack --progress --mode development`
22 error Exit status 1
23 error Failed at the access-ninja@1.0.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

这是我的 monorepo 中的结构:

packages/
├── portal-ui
│   └── package.json
├── access-ninja
        └── package.json

我看到 webpack 启动了,但我不知道它需要做什么工作

您可能需要添加 --config 参数来定义构建脚本所在的位置,因为现在它正在包文件夹中查找。

"build": "webpack --config ../../webpack.config.js --progress --mode development"