Closed konradbartecki closed 2 years ago
Webpack should already be installed in the root node_modules at the repository base. Is it possible you've run npm ci
or npm i
from the cli directory? Since that might cause similar issues to what you've experienced.
I checked again:
npm list -g | grep webpack
:
├─┬ webpack@4.37.0
│ ├─┬ terser-webpack-plugin@1.4.5
│ │ ├── webpack-sources@1.4.3 deduped
│ └─┬ webpack-sources@1.4.3
├─┬ webpack-cli@4.10.0
│ ├── @webpack-cli/configtest@1.2.0
│ ├─┬ @webpack-cli/info@1.5.0
│ ├── @webpack-cli/serve@1.7.0
│ └─┬ webpack-merge@5.8.0
├─┬ webpack-dev-server@4.9.3
│ ├─┬ webpack-dev-middleware@5.3.3
npm uninstall -g webpack webpack-cli webpack-dev-server
node_modules
git reset --hard
npm ci
apps/cli
npm run build:watch
npm run build:watch
> @bitwarden/cli@2022.9.0 build:watch /Users/konrad/Projects/bitwarden-clients/apps/cli
> webpack --watch
sh: webpack: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! @bitwarden/cli@2022.9.0 build:watch: `webpack --watch`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the @bitwarden/cli@2022.9.0 build:watch script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/konrad/.npm/_logs/2022-10-13T14_09_35_067Z-debug.log
Is this only my env issue or other people have the same issue?
I managed to get this working when I had webpack installed globally.
What does your npm list -g | grep webpack
show?
Not all of these are related to bitwarden projects:
>npm list -g
C:\Program Files\nodejs -> .\
├── @angular/cli@13.2.2
├── @compodoc/compodoc@1.1.18
├── corepack@0.10.0
└── npm@8.1.2
This must be an environment related issue. Any errors when running npm ci
?
Environment:
commit 96aba0f994d640b94084d45a5f7cf38939bc28b8
npm version: 6.14.12
macOS 12.6
fish shell
at root directory npm ci
> nice-napi@1.0.2 install /Users/konrad/Projects/bitwarden-clients/node_modules/nice-napi
> node-gyp-build
> esbuild@0.14.49 postinstall /Users/konrad/Projects/bitwarden-clients/node_modules/esbuild
> node install.js
> utf-8-validate@5.0.9 install /Users/konrad/Projects/bitwarden-clients/node_modules/utf-8-validate
> node-gyp-build
> tldjs@2.3.1 postinstall /Users/konrad/Projects/bitwarden-clients/node_modules/tldjs
> node ./bin/postinstall.js
> core-js@2.6.12 postinstall /Users/konrad/Projects/bitwarden-clients/node_modules/babel-runtime/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> core-js@3.24.0 postinstall /Users/konrad/Projects/bitwarden-clients/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"
> bufferutil@4.0.6 install /Users/konrad/Projects/bitwarden-clients/node_modules/bufferutil
> node-gyp-build
> fsevents@1.2.13 install /Users/konrad/Projects/bitwarden-clients/node_modules/glob-watcher/node_modules/fsevents
> node install.js
SOLINK_MODULE(target) Release/.node
CXX(target) Release/obj.target/fse/fsevents.o
SOLINK_MODULE(target) Release/fse.node
> es5-ext@0.10.61 postinstall /Users/konrad/Projects/bitwarden-clients/node_modules/es5-ext
> node -e "try{require('./_postinstall')}catch(e){}" || exit 0
> lzma-native@8.0.6 install /Users/konrad/Projects/bitwarden-clients/node_modules/lzma-native
> node-gyp-build
> electron@19.0.8 postinstall /Users/konrad/Projects/bitwarden-clients/node_modules/electron
> node install.js
> fsevents@1.2.13 install /Users/konrad/Projects/bitwarden-clients/node_modules/watchpack-chokidar2/node_modules/fsevents
> node install.js
SOLINK_MODULE(target) Release/.node
CXX(target) Release/obj.target/fse/fsevents.o
SOLINK_MODULE(target) Release/fse.node
> @compodoc/compodoc@1.1.19 postinstall /Users/konrad/Projects/bitwarden-clients/node_modules/@compodoc/compodoc
> opencollective-postinstall || exit 0
[96m[1mThank you for using @compodoc/compodoc![96m[1m
[0m[96mIf you rely on this package, please consider supporting our open collective:[22m[39m
> [94mhttps://opencollective.com/compodoc/donate[0m
> @bitwarden/clients@0.0.0 prepare /Users/konrad/Projects/bitwarden-clients
> husky install
husky - Git hooks installed
added 3236 packages in 53.452s
then
cd apps/cli
npm run build:watch
sh: webpack: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! @bitwarden/cli@2022.9.0 build:watch: `webpack --watch`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the @bitwarden/cli@2022.9.0 build:watch script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/konrad/.npm/_logs/2022-10-14T15_07_49_311Z-debug.log
contents of debug log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build:watch' ]
2 info using npm@6.14.12
3 info using node@v14.16.1
4 verbose run-script [ 'prebuild:watch', 'build:watch', 'postbuild:watch' ]
5 info lifecycle @bitwarden/cli@2022.9.0~prebuild:watch: @bitwarden/cli@2022.9.0
6 info lifecycle @bitwarden/cli@2022.9.0~build:watch: @bitwarden/cli@2022.9.0
7 verbose lifecycle @bitwarden/cli@2022.9.0~build:watch: unsafe-perm in lifecycle true
8 verbose lifecycle @bitwarden/cli@2022.9.0~build:watch: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/konrad/Projects/bitwarden-clients/apps/cli/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands
9 verbose lifecycle @bitwarden/cli@2022.9.0~build:watch: CWD: /Users/konrad/Projects/bitwarden-clients/apps/cli
10 silly lifecycle @bitwarden/cli@2022.9.0~build:watch: Args: [ '-c', 'webpack --watch' ]
11 info lifecycle @bitwarden/cli@2022.9.0~build:watch: Failed to exec build:watch script
12 verbose stack Error: @bitwarden/cli@2022.9.0 build:watch: `webpack --watch`
12 verbose stack spawn ENOENT
12 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
12 verbose stack at ChildProcess.emit (events.js:315:20)
12 verbose stack at maybeClose (internal/child_process.js:1048:16)
12 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
13 verbose pkgid @bitwarden/cli@2022.9.0
14 verbose cwd /Users/konrad/Projects/bitwarden-clients/apps/cli
15 verbose Darwin 21.6.0
16 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build:watch"
17 verbose node v14.16.1
18 verbose npm v6.14.12
19 error code ELIFECYCLE
20 error syscall spawn
21 error file sh
22 error errno ENOENT
23 error @bitwarden/cli@2022.9.0 build:watch: `webpack --watch`
23 error spawn ENOENT
24 error Failed at the @bitwarden/cli@2022.9.0 build:watch script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]
Not sure if this is the root cause, but I noticed you are using an older version of npm
.
Please update it to at least v8 and also check if there are any other tools needed/or need updating based on our setup instructions in our Contribution Guidelines
Tested with a recent Ubuntu VM and there it works out of the box. Turns out Volta made my shell point to an older npm. When I made my shell to point to an npm v8 then everything works.
Side note, when I use an older npm version I do not get this message:
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@bitwarden/clients@0.0.0',
npm WARN EBADENGINE required: { node: '~16', npm: '~8' },
npm WARN EBADENGINE current: { node: 'v18.11.0', npm: '8.19.2' }
npm WARN EBADENGINE }
It is shown only when node version differs.
Issue can be closed, thanks a lot!
Steps To Reproduce
On a new clean dev environment:
npm ci
cd apps/cli
npm run build:watch
Expected Result
CLI app builds
Actual Result
App will either silently fail build or complain about missing webpack.
Screenshots or Videos
No response
Additional Context
Installing multiple versions of following packages fixes the problem:
webpack
webpack-cli
webpack-dev-server
Operating System
macOS
Operating System Version
macOS 12.6
Shell
Bash
Build Version
6.14.12