1.解決したい問題
Salesforce の Lightning Web Componentsをローカルで動かすために@salesforce/lwc-dev-server
をインストールしたいが、Error: spawn node-gyp ENOENT
のエラーが発生してしまってインストールできない。
kanayatBookpuro:lex_playground taichikanaya$ sfdx plugins:install @salesforce/lwc-dev-server
Successfully validated digital signature for @salesforce/lwc-dev-server.
Finished digital signature check.
warning "@salesforce/lwc-dev-server > @rollup/plugin-alias@3.1.2" has unmet peer dependency "rollup@^1.20.0||^2.0.0".
warning "@salesforce/lwc-dev-server > request-promise-native@1.0.9" has unmet peer dependency "request@^2.34".
warning "@salesforce/lwc-dev-server > request-promise-native > request-promise-core@1.1.4" has unmet peer dependency "request@^2.34".
warning Error running install script for optional dependency: "/Users/taichikanaya/.local/share/sfdx/node_modules/cpx/node_modules/fsevents: Command failed.
Exit code: 1
Command: node install.js
Arguments:
Directory: /Users/taichikanaya/.local/share/sfdx/node_modules/cpx/node_modules/fsevents
Output:
events.js:292
throw er; // Unhandled 'error' event
^
Error: spawn node-gyp ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
Emitted 'error' event on ChildProcess instance at:
at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)
at onErrorNT (internal/child_process.js:469:16)
at processTicksAndRejections (internal/process/task_queues.js:84:21) {
errno: 'ENOENT',
code: 'ENOENT',
syscall: 'spawn node-gyp',
path: 'node-gyp',
spawnargs: [ 'rebuild' ]
}"
Installing plugin @salesforce/lwc-dev-server... installed v2.10.0
kanayatBookpuro:lex_playground taichikanaya$
2.環境情報
kanayatBookpuro:lex_playground taichikanaya$ sfdx -v
sfdx-cli/7.78.1-5a65d9dd2f darwin-x64 node-v12.18.3
kanayatBookpuro:lex_playground taichikanaya$ node -v
v12.21.0
kanayatBookpuro:lex_playground taichikanaya$
##3.対処方法
node-gyp
がインストールされていないようだったのでインストールしたら解決しました。
kanayatBookpuro:lex_playground taichikanaya$ which node-gyp
kanayatBookpuro:lex_playground taichikanaya$ npm install -g node-gyp
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
/Users/taichikanaya/.nvm/versions/node/v12.21.0/bin/node-gyp -> /Users/taichikanaya/.nvm/versions/node/v12.21.0/lib/node_modules/node-gyp/bin/node-gyp.js
+ node-gyp@7.1.2
added 97 packages from 66 contributors in 12.345s
kanayatBookpuro:lex_playground taichikanaya$
node-gyp
インストール後のsfdx plugins:xxx
の実行結果↓
kanayatBookpuro:lex_playground taichikanaya$ sfdx plugins:install @salesforce/lwc-dev-server
Successfully validated digital signature for @salesforce/lwc-dev-server.
Finished digital signature check.
warning "@salesforce/lwc-dev-server > @rollup/plugin-alias@3.1.2" has unmet peer dependency "rollup@^1.20.0||^2.0.0".
warning "@salesforce/lwc-dev-server > request-promise-native@1.0.9" has unmet peer dependency "request@^2.34".
warning "@salesforce/lwc-dev-server > request-promise-native > request-promise-core@1.1.4" has unmet peer dependency "request@^2.34".
Installing plugin @salesforce/lwc-dev-server... installed v2.10.0
kanayatBookpuro:lex_playground taichikanaya$
kanayatBookpuro:lex_playground taichikanaya$ sfdx plugins:update
warning "@salesforce/lwc-dev-server > @rollup/plugin-alias@3.1.2" has unmet peer dependency "rollup@^1.20.0||^2.0.0".
warning "@salesforce/lwc-dev-server > request-promise-native@1.0.9" has unmet peer dependency "request@^2.34".
warning "@salesforce/lwc-dev-server > request-promise-native > request-promise-core@1.1.4" has unmet peer dependency "request@^2.34".
sfdx-cli: Updating plugins... done
kanayatBookpuro:lex_playground taichikanaya$
私の場合は上記で解決しました。以上終わり。