LoginSignup
3
1

More than 3 years have passed since last update.

puppeteerでThis relative module was not found: ~ ws ~ WebSocketTransport.js

Last updated at Posted at 2020-02-22

環境

・windows10
・vue-cli3
・electron-builder

現象

electronでpuppeteerを使おうとした。
npm run electron:serveしたら、

This dependency was not found:

* ws in ./node_modules/puppeteer/lib/WebSocketTransport.js

To install it, you can run: npm install --save ws

対応

To install it, you can run: npm install --save ws

とあるので言われたとおりにコマンドを打つ。
で、再度build。
しかし、同じエラーが…。

解決策

node_modules/puppeteer/lib/WebSocketTransport.jsをいじる。

const WebSocket = require('ws');

const WebSocket = require('../node_modules/ws');

に修正する。(wsをnpm installした後に)

備考

issueはこちら
https://github.com/puppeteer/puppeteer/issues/3487

自分の環境ではこの方法で助かったが、リンク先は割と紛糾しているみたい?
この分野(electron+αの開発)は日本語の参考記事も少ないので、じぶんみたいなぺーぺーだとわりと簡単なところで結構つまづく。

3
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
1