vanilla-clipper icon indicating copy to clipboard operation
vanilla-clipper copied to clipboard

Error: Cannot find module 'luxon'

Open gomo opened this issue 6 years ago • 6 comments

いいツールを見つけた!と思ったらタイトルのエラーで途中で止まってしまいます。

$ vanilla-clipper -n https://qiita.com

module.js:550
    throw err;
    ^

Error: Cannot find module 'luxon'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/masamoto/.config/yarn/global/node_modules/vanilla-clipper/dist/utils/index.js:18:17)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)

試しにyarn global add luxonしたら動きました。

https://github.com/yarnaimo/vanilla-clipper/blob/7eaba81cb657ed8c66e1de5af2cea45de494b187/package.json#L26-L45

パッケージの追加漏れではないでしょうか?

gomo avatar Jun 06 '19 09:06 gomo

すいません、もう一点。デバイスを指定すると下記のエラーで実行できません。

$vanilla-clipper -l ja-JP --device 'iPhone 6' -n https://qiita.com

☐  pending   [1/1] Clipping https://qiita.com
✖  error     Error: JSHandles can be evaluated only in the context they were created! 
    at ExecutionContext.convertArgument (/Users/masamoto/.config/yarn/global/node_modules/puppeteer-core/lib/ExecutionContext.js:143:17)
    at Array.map (<anonymous>)
    at ExecutionContext.evaluateHandle (/Users/masamoto/.config/yarn/global/node_modules/puppeteer-core/lib/ExecutionContext.js:109:25)
    at ExecutionContext.<anonymous> (/Users/masamoto/.config/yarn/global/node_modules/puppeteer-core/lib/helper.js:111:23)
    at ExecutionContext.evaluate (/Users/masamoto/.config/yarn/global/node_modules/puppeteer-core/lib/ExecutionContext.js:48:31)
    at ExecutionContext.<anonymous> (/Users/masamoto/.config/yarn/global/node_modules/puppeteer-core/lib/helper.js:111:23)
    at DOMWorld.evaluate (/Users/masamoto/.config/yarn/global/node_modules/puppeteer-core/lib/DOMWorld.js:112:20)
    at <anonymous>
  -- ASYNC --
    at Frame.<anonymous> (/Users/masamoto/.config/yarn/global/node_modules/puppeteer-core/lib/helper.js:110:27)
    at Page.evaluate (/Users/masamoto/.config/yarn/global/node_modules/puppeteer-core/lib/Page.js:782:43)
    at Page.<anonymous> (/Users/masamoto/.config/yarn/global/node_modules/puppeteer-core/lib/helper.js:111:23)
    at VDocument.eval (/Users/masamoto/.config/yarn/global/node_modules/vanilla-clipper/dist/core/VDocument.js:16:48)
    at VDocument.setUuidToIFramesAndShadowHosts (/Users/masamoto/.config/yarn/global/node_modules/vanilla-clipper/dist/core/VDocument.js:58:27)
    at VPage.clip (/Users/masamoto/.config/yarn/global/node_modules/vanilla-clipper/dist/core/VFrame.js:23:32)
    at <anonymous>
(node:7611) UnhandledPromiseRejectionWarning: Error: Navigation failed because browser has disconnected!
    at CDPSession.LifecycleWatcher._eventListeners.helper.addEventListener (/Users/masamoto/.config/yarn/global/node_modules/puppeteer-core/lib/LifecycleWatcher.js:46:107)
    at emitNone (events.js:106:13)
    at CDPSession.emit (events.js:208:7)
    at CDPSession._onClosed (/Users/masamoto/.config/yarn/global/node_modules/puppeteer-core/lib/Connection.js:215:10)
    at Connection._onMessage (/Users/masamoto/.config/yarn/global/node_modules/puppeteer-core/lib/Connection.js:105:17)
    at WebSocketTransport._ws.addEventListener.event (/Users/masamoto/.config/yarn/global/node_modules/puppeteer-core/lib/WebSocketTransport.js:41:24)
    at WebSocket.onMessage (/Users/masamoto/.config/yarn/global/node_modules/ws/lib/event-target.js:120:16)
    at emitOne (events.js:116:13)
    at WebSocket.emit (events.js:211:7)
    at Receiver.receiverOnMessage (/Users/masamoto/.config/yarn/global/node_modules/ws/lib/websocket.js:789:20)
    at emitOne (events.js:116:13)
    at Receiver.emit (events.js:211:7)
    at Receiver.dataMessage (/Users/masamoto/.config/yarn/global/node_modules/ws/lib/receiver.js:422:14)
    at Receiver.getData (/Users/masamoto/.config/yarn/global/node_modules/ws/lib/receiver.js:352:17)
    at Receiver.startLoop (/Users/masamoto/.config/yarn/global/node_modules/ws/lib/receiver.js:138:22)
    at Receiver._write (/Users/masamoto/.config/yarn/global/node_modules/ws/lib/receiver.js:74:10)
  -- ASYNC --
    at Frame.<anonymous> (/Users/masamoto/.config/yarn/global/node_modules/puppeteer-core/lib/helper.js:110:27)
    at Page.waitForNavigation (/Users/masamoto/.config/yarn/global/node_modules/puppeteer-core/lib/Page.js:649:49)
    at Page.<anonymous> (/Users/masamoto/.config/yarn/global/node_modules/puppeteer-core/lib/helper.js:111:23)
    at Page.reload (/Users/masamoto/.config/yarn/global/node_modules/puppeteer-core/lib/Page.js:638:12)
    at Page.<anonymous> (/Users/masamoto/.config/yarn/global/node_modules/puppeteer-core/lib/helper.js:111:23)
    at Page.setViewport (/Users/masamoto/.config/yarn/global/node_modules/puppeteer-core/lib/Page.js:766:18)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
  -- ASYNC --
    at Page.<anonymous> (/Users/masamoto/.config/yarn/global/node_modules/puppeteer-core/lib/helper.js:110:27)
    at VPage.setViewportHeight (/Users/masamoto/.config/yarn/global/node_modules/vanilla-clipper/dist/core/VPage.js:18:20)
    at VPage.clip (/Users/masamoto/.config/yarn/global/node_modules/vanilla-clipper/dist/core/VFrame.js:17:24)
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:189:7)
(node:7611) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 3)
(node:7611) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

puppeteer-coreがyarn/global/node_modules/puppeteer-coreを見ていて、

https://github.com/yarnaimo/vanilla-clipper/blob/master/yarn.lock#L4630

https://github.com/yarnaimo/vanilla-clipper/blob/7eaba81cb657ed8c66e1de5af2cea45de494b187/yarn.lock#L4630-L4642

バーションが1.11.0を使っているようですが、私のyarn/global/node_modules/puppeteer-core1.17.0です。おそらくバージョン違いのせいかなと想像してるのですが、puppeteer系はdevDependencies ではなくdependencies に入れると安定して動くような気がするのですがそんなことないでしょうか?

ご検討お願いします。

gomo avatar Jun 06 '19 09:06 gomo

puppeteer系はdevDependencies ではなくdependencies に入れると安定して動くような気がするのですがそんなことないでしょうか?

すいません、既にcoreは入ってましたね。

https://github.com/gomo/vanilla-clipper/blob/7eaba81cb657ed8c66e1de5af2cea45de494b187/package.json#L39

私のyarn/global/node_modules/vanilla-clipper/node_modulespuppeteer-coreが無いのでてっきり入ってないと思い込んでしまいました。失礼。

上記のエラーがバージョンが原因だったらという前提ですがバージョン指定を~1.11.0にするか、新しいバージョンでも動くようにするか、どちらかという感じですかね?

私の方でもバージョンが原因なのか頑張って調査してみます。

gomo avatar Jun 06 '19 10:06 gomo

@yarnaimo

Forkして~1.11.0に変更、バージョン1.11で試しました。結論を言うとバージョンの問題ではなさそうですね。

node dist/bin/clip.js -l ja-JP --device 'iPhone 6' -n https://qiita.com
☐  pending   [1/1] Clipping https://qiita.com
✖  error     Error: JSHandles can be evaluated only in the context they were created! 
    at ExecutionContext.convertArgument (/Users/masamoto/Documents/repos/home/source/sites/vanilla-clipper/node_modules/puppeteer-core/lib/ExecutionContext.js:144:17)
    at Array.map (<anonymous>)
    at ExecutionContext.evaluateHandle (/Users/masamoto/Documents/repos/home/source/sites/vanilla-clipper/node_modules/puppeteer-core/lib/ExecutionContext.js:118:23)
    at ExecutionContext.<anonymous> (/Users/masamoto/Documents/repos/home/source/sites/vanilla-clipper/node_modules/puppeteer-core/lib/helper.js:145:23)
    at ExecutionContext.evaluate (/Users/masamoto/Documents/repos/home/source/sites/vanilla-clipper/node_modules/puppeteer-core/lib/ExecutionContext.js:58:31)
    at ExecutionContext.<anonymous> (/Users/masamoto/Documents/repos/home/source/sites/vanilla-clipper/node_modules/puppeteer-core/lib/helper.js:145:23)
    at Frame.evaluate (/Users/masamoto/Documents/repos/home/source/sites/vanilla-clipper/node_modules/puppeteer-core/lib/FrameManager.js:447:20)
    at <anonymous>
  -- ASYNC --
    at Frame.<anonymous> (/Users/masamoto/Documents/repos/home/source/sites/vanilla-clipper/node_modules/puppeteer-core/lib/helper.js:144:27)
    at Page.evaluate (/Users/masamoto/Documents/repos/home/source/sites/vanilla-clipper/node_modules/puppeteer-core/lib/Page.js:777:43)
    at Page.<anonymous> (/Users/masamoto/Documents/repos/home/source/sites/vanilla-clipper/node_modules/puppeteer-core/lib/helper.js:145:23)
    at VDocument.eval (/Users/masamoto/Documents/repos/home/source/sites/vanilla-clipper/dist/core/VDocument.js:16:48)
    at VDocument.setUuidToIFramesAndShadowHosts (/Users/masamoto/Documents/repos/home/source/sites/vanilla-clipper/dist/core/VDocument.js:58:27)
    at VPage.clip (/Users/masamoto/Documents/repos/home/source/sites/vanilla-clipper/dist/core/VFrame.js:23:32)
    at <anonymous>

とりあえず、今日はここまでにします!何か分かりましたお願いします。

gomo avatar Jun 06 '19 10:06 gomo

詳しいところまでありがとうございます!

luxonは @yarnaimo/rain0.2.7 には含まれていたんですが、最新バージョンには含まれていなかったようで latest0.2.7 に変えたら直りました。

デバイスの指定も調査してみます。

yarnaimo avatar Jun 06 '19 12:06 yarnaimo

@yarnaimo

luxonは @yarnaimo/rain0.2.7 には含まれていたんですが、最新バージョンには含まれていなかったようで latest0.2.7 に変えたら直りました。

vanilla-clipperアップグレードして、グローバルに入れたluxonを削除後、無事起動することを確認しました。ありがとうございます。

デバイスの指定も調査してみます。

宜しくお願いします!

gomo avatar Jun 07 '19 01:06 gomo

@yarnaimo

全然関係ないかもしれませんが、Chrome75からSeleniumのオプションが効かなくなっていました。

https://qiita.com/MasamotoMiyata/items/079dcc9d497586dbb8ad

Seleniumだし、私の場合はエラーにもならずにブラウザが起動しオプションが効かないだけだったので全く関係ないかもしれませんが、mobileEmulation: { deviceName: "iPhone 6" }のオプションも効かなくなっていたのでもしかしたら?と思ったので共有しておきます。

gomo avatar Jun 07 '19 07:06 gomo