🍉
Playwrightの公式Dockerイメージでnpx playwright
Playwrightの公式Dockerイメージでnpx playwrightを実行すると、こんなエラーが出る。
$ docker run -it --rm mcr.microsoft.com/playwright:v1.14.1 npx playwright@1.14.1
internal/modules/cjs/loader.js:892
throw err;
^
Error: Cannot find module '/root/.npm/_npx/1/lib/node_modules/playwright/install.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15)
at Function.Module._load (internal/modules/cjs/loader.js:745:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
npm ERR! code ELIFECYCLE
(略)
マイクロソフトなので当然ない。
unsafe-perm=true にすればよい
エラーメッセージでググると
unsafe-permってフラグをtrueにせよと書いてある。ただ、npmであればこのパラメータがあるが、npxにはない。
どうすればいいか調べたところ、Qiitaに全く同じことを書いてる人が居た。
dockerコマンドなので、 -e npm_config_unsafe_perm=true
を指定すれば良さそう。
$ docker run -it --rm -e npm_config_unsafe_perm=true mcr.microsoft.com/playwright:v1.14.1 npx playwright@1.14.1
Usage: npx playwright [options] [command]
Options:
-V, --version output the version number
-h, --help display help for command
Commands:
open [options] [url] open page in browser specified via -b, --browser
codegen [options] [url] open page and generate code for user actions
debug <app> [args...] run command in debug mode: disable timeout, open inspector
install [options] [browser...] ensure browsers necessary for this version of Playwright are installed
install-deps [browser...] install dependencies necessary to run browsers (will ask for sudo
permissions)
cr [options] [url] open page in Chromium
ff [options] [url] open page in Firefox
wk [options] [url] open page in WebKit
screenshot [options] <url> <filename> capture a page screenshot
pdf [options] <url> <filename> save page as pdf
show-trace [options] [trace] Show trace viewer
test Run tests with Playwright Test. Available in @playwright/test package.
きたきたーー
Discussion