Home > Software engineering >  Installing playwright using npm gives error `command failed`
Installing playwright using npm gives error `command failed`

Time:07-22

I tried to install playwright using the command

npm i playwright

But got an error

npm ERR! code 1
npm ERR! path C:\Users\hpoddar\node_modules\playwright
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node install.js

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\hpoddar\AppData\Local\npm-cache\_logs\2022-07-22T08_07_17_487Z-debug-0.log

2022-07-22T08_07_17_487Z-debug-0.log says

0 verbose cli [
0 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
0 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
0 verbose cli   'i',
0 verbose cli   'playwright'
0 verbose cli ]
1 info using [email protected]
2 info using [email protected]
3 timing npm:load:whichnode Completed in 0ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:C:\Program Files\nodejs\node_modules\npm\npmrc Completed in 2ms
6 timing config:load:builtin Completed in 3ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 0ms
9 timing config:load:project Completed in 2ms
10 timing config:load:file:C:\Users\hpoddar\.npmrc Completed in 0ms
11 timing config:load:user Completed in 0ms
12 timing config:load:file:C:\Users\hpoddar\AppData\Roaming\npm\etc\npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:validate Completed in 0ms
15 timing config:load:credentials Completed in 0ms
16 timing config:load:setEnvs Completed in 1ms
17 timing config:load Completed in 9ms
18 timing npm:load:configload Completed in 9ms
19 timing npm:load:setTitle Completed in 0ms
20 timing config:load:flatten Completed in 1ms
21 timing npm:load:display Completed in 3ms
22 verbose logfile C:\Users\hpoddar\AppData\Local\npm-cache\_logs\2022-07-22T08_07_17_487Z-debug-0.log
23 timing npm:load:logFile Completed in 5ms
24 timing npm:load:timers Completed in 0ms
25 timing npm:load:configScope Completed in 0ms
26 timing npm:load Completed in 17ms
27 timing arborist:ctor Completed in 1ms
28 silly logfile start cleaning logs, removing 4 files
29 timing arborist:ctor Completed in 0ms
30 timing idealTree:init Completed in 6ms
31 timing idealTree:userRequests Completed in 2ms
32 silly idealTree buildDeps
33 silly fetch manifest playwright@*
34 http fetch GET 200 https://registry.npmjs.org/playwright 24ms (cache hit)
35 silly placeDep ROOT [email protected] OK for:  want: *
36 silly fetch manifest [email protected]
37 http fetch GET 200 https://registry.npmjs.org/playwright-core 20ms (cache hit)
38 timing idealTree:#root Completed in 87ms
39 silly placeDep ROOT [email protected] OK for: [email protected] want: 1.24.0
40 timing idealTree:node_modules/playwright Completed in 2ms
41 timing idealTree:node_modules/playwright-core Completed in 0ms
42 timing idealTree:buildDeps Completed in 89ms
43 timing idealTree:fixDepFlags Completed in 1ms
44 timing idealTree Completed in 99ms
45 timing reify:loadTrees Completed in 99ms
46 timing reify:diffTrees Completed in 1ms
47 silly reify moves {}
48 timing reify:retireShallow Completed in 0ms
49 timing reify:createSparse Completed in 7ms
50 timing reify:loadBundles Completed in 0ms
51 silly audit bulk request { playwright: [ '1.24.0' ], 'playwright-core': [ '1.24.0' ] }
52 timing reifyNode:node_modules/playwright Completed in 58ms
53 timing reifyNode:node_modules/playwright-core Completed in 454ms
54 timing reify:unpack Completed in 454ms
55 timing reify:unretire Completed in 0ms
56 timing build:queue Completed in 1ms
57 timing build:link:node_modules/playwright-core Completed in 0ms
58 timing build:link:node_modules/playwright Completed in 6ms
59 timing build:link Completed in 6ms
60 info run [email protected] install node_modules/playwright node install.js
61 http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/advisories/bulk 606ms
62 timing auditReport:getReport Completed in 607ms
63 silly audit report {}
64 timing auditReport:init Completed in 0ms
65 timing reify:audit Completed in 608ms
66 info run [email protected] install { code: 1, signal: null }
67 timing reify:rollback:createSparse Completed in 618ms
68 timing reify:rollback:retireShallow Completed in 0ms
69 timing command:i Completed in 8869ms
70 verbose stack Error: command failed
70 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\@npmcli\promise-spawn\index.js:64:27)
70 verbose stack     at ChildProcess.emit (node:events:526:28)
70 verbose stack     at maybeClose (node:internal/child_process:1092:16)
70 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
71 verbose pkgid [email protected]
72 verbose cwd C:\Users\hpoddar
73 verbose Windows_NT 10.0.22000
74 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "i" "playwright"
75 verbose node v16.14.2
76 verbose npm  v8.5.0
77 error code 1
78 error path C:\Users\hpoddar\node_modules\playwright
79 error command failed
80 error command C:\Windows\system32\cmd.exe /d /s /c node install.js
81 verbose exit 1
82 timing npm Completed in 9246ms
83 verbose unfinished npm timer reify 1658477237859
84 verbose unfinished npm timer reify:build 1658477238429
85 verbose unfinished npm timer build 1658477238429
86 verbose unfinished npm timer build:deps 1658477238429
87 verbose unfinished npm timer build:run:install 1658477238436
88 verbose unfinished npm timer build:run:install:node_modules/playwright 1658477238436
89 verbose code 1

CodePudding user response:

You can delete the node_modules folder and the package-lock.json file and try running the command again.

There are two other ways you can install Playwright.

  1. Using the interactive way as mentioned in the playwright docs
npm init playwright@latest
  1. Using the sequence of commands (Reference):
npm i -D @playwright/test

# install supported browsers
npx playwright install
  • Related