cypress-io / cypress

Fast, easy and reliable testing for anything that runs in a browser.
https://cypress.io
MIT License
46.85k stars 3.17k forks source link

Error during installation #28862

Closed logrox closed 8 months ago

logrox commented 8 months ago

Current behavior

$ npm i cypress@13.6.4 --unsafe-perm=true --allow-root
npm ERR! code 1
npm ERR! path /home/[user]/WebstormProjects/[project]/node_modules/cypress
npm ERR! command failed
npm ERR! command sh -c node index.js --exec install

Debug logs

0 verbose cli /snap/node/8169/bin/node /usr/local/bin/npm
1 info using npm@10.4.0
2 info using node@v20.11.0
3 timing npm:load:whichnode Completed in 1ms
4 timing config:load:defaults Completed in 1ms
5 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 0ms
6 timing config:load:builtin Completed in 0ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:/home/[user]/WebstormProjects/[project]/.npmrc Completed in 0ms
10 timing config:load:project Completed in 2ms
11 timing config:load:file:/home/[user]/.npmrc Completed in 0ms
12 timing config:load:user Completed in 0ms
13 timing config:load:file:/snap/node/8169/etc/npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:setEnvs Completed in 0ms
16 timing config:load Completed in 6ms
17 timing npm:load:configload Completed in 6ms
18 timing config:load:flatten Completed in 1ms
19 timing npm:load:mkdirpcache Completed in 0ms
20 timing npm:load:mkdirplogs Completed in 0ms
21 verbose title npm i cypress@13.6.4
22 verbose argv "i" "cypress@13.6.4" "--unsafe-perm" "true" "--allow-root"
23 timing npm:load:setTitle Completed in 0ms
24 timing npm:load:display Completed in 0ms
25 verbose logfile logs-max:10 dir:/home/[user]/.npm/_logs/2024-02-05T07_23_17_313Z-
26 verbose logfile /home/[user]/.npm/_logs/2024-02-05T07_23_17_313Z-debug-0.log
27 timing npm:load:logFile Completed in 5ms
28 timing npm:load:timers Completed in 0ms
29 timing npm:load:configScope Completed in 0ms
30 timing npm:load Completed in 22ms
31 timing arborist:ctor Completed in 1ms
32 silly logfile start cleaning logs, removing 1 files
33 silly logfile done cleaning log files
34 timing idealTree:init Completed in 412ms
35 timing idealTree:userRequests Completed in 2ms
36 silly idealTree buildDeps
37 silly fetch manifest cypress@13.6.4
38 verbose shrinkwrap failed to load node_modules/.package-lock.json out of date, updated: node_modules
39 http fetch GET 200 https://registry.npmjs.org/cypress 16ms (cache hit)
40 silly placeDep ROOT cypress@13.6.4 REPLACE for: smok@15.16.0 want: 13.6.4
41 timing idealTree:#root Completed in 41ms
42 timing idealTree:node_modules/cypress Completed in 0ms
43 timing idealTree:buildDeps Completed in 41ms
44 timing idealTree:fixDepFlags Completed in 4ms
45 timing idealTree Completed in 465ms
46 timing reify:loadTrees Completed in 883ms
47 timing reify:diffTrees Completed in 13ms
48 silly reify mark retired [
48 silly reify   '/home/[user]/WebstormProjects/[project]/node_modules/cypress',
48 silly reify   '/home/[user]/WebstormProjects/[project]/node_modules/.bin/cypress'
48 silly reify ]
49 silly reify moves {
49 silly reify   '/home/[user]/WebstormProjects/[project]/node_modules/cypress': '/home/[user]/WebstormProjects/[project]/node_modules/.cypress-sbAAc51c',
49 silly reify   '/home/[user]/WebstormProjects/[project]/node_modules/.bin/cypress': '/home/[user]/WebstormProjects/[project]/node_modules/.bin/.cypress-CaKvOXka'
49 silly reify }
50 timing reify:retireShallow Completed in 2ms
51 timing reify:createSparse Completed in 0ms
52 timing reify:loadBundles Completed in 0ms
53 silly audit bulk request {
...
}
54 verbose reify failed optional dependency /home/[user]/WebstormProjects/[project]/node_modules/fsevents
55 silly reify mark deleted [ '/home/[user]/WebstormProjects/[project]/node_modules/fsevents' ]
56 timing reifyNode:node_modules/fsevents Completed in 32ms
57 timing reifyNode:node_modules/cypress Completed in 140ms
58 timing reify:unpack Completed in 141ms
59 timing reify:unretire Completed in 4ms
60 timing build:queue Completed in 0ms
61 timing build:link:node_modules/cypress Completed in 1ms
62 timing build:link Completed in 1ms
63 info run cypress@13.6.4 postinstall node_modules/cypress node index.js --exec install
64 http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/advisories/bulk 279ms
65 timing auditReport:getReport Completed in 288ms
66 silly audit report {
66 silly audit report   semver: [
66 silly audit report     {
66 silly audit report       id: 1095366,
66 silly audit report       url: 'https://github.com/advisories/GHSA-c2qf-rxjj-qqgw',
66 silly audit report       title: 'semver vulnerable to Regular Expression Denial of Service',
66 silly audit report       severity: 'moderate',
66 silly audit report       vulnerable_versions: '>=6.0.0 <6.3.1',
66 silly audit report       cwe: [Array],
66 silly audit report       cvss: [Object]
66 silly audit report     }
66 silly audit report   ],
66 silly audit report   'word-wrap': [
66 silly audit report     {
66 silly audit report       id: 1095091,
66 silly audit report       url: 'https://github.com/advisories/GHSA-j8xg-fqg3-53r7',
66 silly audit report       title: 'word-wrap vulnerable to Regular Expression Denial of Service',
66 silly audit report       severity: 'moderate',
66 silly audit report       vulnerable_versions: '<1.2.4',
66 silly audit report       cwe: [Array],
66 silly audit report       cvss: [Object]
66 silly audit report     }
66 silly audit report   ]
66 silly audit report }
67 timing metavuln:cache:get:security-advisory:semver:B2yCVDuSmLf8332mhGhg1S6Zd7Koie5xyRZDXEe2xdprLBYcYjJgahmRqKRNsryDFUzhmwYo3ZKc1tOJhj2lvA== Completed in 2ms
68 timing metavuln:cache:get:security-advisory:word-wrap:KsI0N1m15Rt6tEZu1EDy6byAPYGo9k6gf5vUtxXQhGu5Snvftcd9klOfEjZk/al0ffowP1mOrgveD8ncFA/ntA== Completed in 2ms
69 http fetch GET 200 https://registry.npmjs.org/semver 29ms (cache revalidated)
70 timing metavuln:packument:semver Completed in 29ms
71 timing metavuln:load:security-advisory:semver:1095366 Completed in 1ms
72 timing metavuln:calculate:security-advisory:semver:1095366 Completed in 30ms
73 http fetch GET 200 https://registry.npmjs.org/word-wrap 51ms (cache revalidated)
74 timing metavuln:packument:word-wrap Completed in 51ms
75 timing metavuln:load:security-advisory:word-wrap:1095091 Completed in 0ms
76 timing metavuln:calculate:security-advisory:word-wrap:1095091 Completed in 51ms
77 timing metavuln:cache:get:security-advisory:istanbul-lib-instrument:YGCwnm36JrSBz4fBWjQBzcSPv8wEYaLXtgfCWXoK+EtreEfF/B11YJRhZtQ1LYO7ZvvUyLAjlD5qBzSDuYBa9Q== Completed in 1ms
78 http fetch GET 200 https://registry.npmjs.org/istanbul-lib-instrument 24ms (cache revalidated)
79 timing metavuln:packument:istanbul-lib-instrument Completed in 25ms
80 timing metavuln:load:security-advisory:istanbul-lib-instrument:B2yCVDuSmLf8332mhGhg1S6Zd7Koie5xyRZDXEe2xdprLBYcYjJgahmRqKRNsryDFUzhmwYo3ZKc1tOJhj2lvA== Completed in 0ms
81 timing metavuln:calculate:security-advisory:istanbul-lib-instrument:B2yCVDuSmLf8332mhGhg1S6Zd7Koie5xyRZDXEe2xdprLBYcYjJgahmRqKRNsryDFUzhmwYo3ZKc1tOJhj2lvA== Completed in 25ms
82 timing metavuln:cache:get:security-advisory:optionator:/960sUo/6A36MG91x/KDKvQmrtWNnYImhDzVHB/xKRxGBVSTtX/fw2U457HYAiqgvl/7p2Ad8tcuOOIdIZG01Q== Completed in 1ms
83 http fetch GET 200 https://registry.npmjs.org/optionator 28ms (cache revalidated)
84 timing metavuln:packument:optionator Completed in 28ms
85 timing metavuln:load:security-advisory:optionator:KsI0N1m15Rt6tEZu1EDy6byAPYGo9k6gf5vUtxXQhGu5Snvftcd9klOfEjZk/al0ffowP1mOrgveD8ncFA/ntA== Completed in 0ms
86 timing metavuln:calculate:security-advisory:optionator:KsI0N1m15Rt6tEZu1EDy6byAPYGo9k6gf5vUtxXQhGu5Snvftcd9klOfEjZk/al0ffowP1mOrgveD8ncFA/ntA== Completed in 28ms
87 timing auditReport:init Completed in 108ms
88 timing reify:audit Completed in 396ms
89 info run cypress@13.6.4 postinstall { code: 1, signal: null }
90 timing reify:rollback:createSparse Completed in 11ms
91 timing reify:rollback:retireShallow Completed in 0ms
92 timing command:i Completed in 1863ms
93 verbose stack Error: command failed
93 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:53:27)
93 verbose stack     at ChildProcess.emit (node:events:518:28)
93 verbose stack     at maybeClose (node:internal/child_process:1105:16)
93 verbose stack     at ChildProcess._handle.onexit (node:internal/child_process:305:5)
94 verbose pkgid cypress@13.6.4
95 verbose cwd /home/[user]/WebstormProjects/[project]
96 verbose Linux 5.14.0-1048-oem
97 verbose node v20.11.0
98 verbose npm  v10.4.0
99 error code 1
100 error path /home/[user]/WebstormProjects/[project]/node_modules/cypress
101 error command failed
102 error command sh -c node index.js --exec install
103 verbose exit 1
104 timing npm Completed in 1978ms
105 verbose unfinished npm timer reify 1707117797427
106 verbose unfinished npm timer reify:build 1707117798484
107 verbose unfinished npm timer build 1707117798484
108 verbose unfinished npm timer build:deps 1707117798485
109 verbose unfinished npm timer build:run:postinstall 1707117798486
110 verbose unfinished npm timer build:run:postinstall:node_modules/cypress 1707117798486
111 verbose code 1
112 error A complete log of this run can be found in: /home/[user]/.npm/_logs/2024-02-05T07_23_17_313Z-debug-0.log

Cypress Version

13.6.4

Node version

20.11.0

Package Manager

npm

Package Manager Version

10.4.0

Operating system

Linux

Operating System Version

Ubuntu 22.04.3

Other

64Bit; Gnome:42.9

jennifer-shehane commented 8 months ago

@logrox I can't really track down from the logs that this is an issue with Cypress itself. Does this happen on every install you try of Cypress?

logrox commented 8 months ago

@logrox I can't really track down from the logs that this is an issue with Cypress itself. Does this happen on every install you try of Cypress?

This is what happens every time I install. What's worse, even when creating a new project from scratch, npm init; npm install cypress; Then there is also a problem. Additionally, I only have this problem on the mentioned system. For the Ubuntu version without a graphical environment (production), everything is OK. It is also fine for the Docker version. I have been struggling with this for 2 weeks, if the problem is not solved, I will reinstall the system.

logrox commented 8 months ago

I found a solution to the problem. I had NodeJS installed with Ubuntu Software. I uninstalled and downloaded from https://github.com/nodesource/distributions?tab=readme-ov-file#using-ubuntu.

It remains to determine why Ubuntu Software does not work.

MikeMcC399 commented 8 months ago

@logrox

You normally do not need to install the source of Node.js (https://github.com/nodesource/distributions?tab=readme-ov-file#using-ubuntu) in order to install Cypress.

In practice it is convenient on Ubuntu to install Node.js with a node-version manager so that you can easily switch between versions for testing. There is a list of these on https://github.com/shadowspawn/node-version-usage. I use n – Interactively Manage Your Node.js Versions on Ubuntu and that is my personal preference.

zeno-ce commented 3 months ago

I experienced the same problem when installing cypress on both pop_os and Ubuntu 24.04 but only when node was installed as a snap. When I installed node using apt the problem was resolved. Seems related to a (lack of) permissions when node is running as a snap.

MikeMcC399 commented 3 months ago

@zeno-ce

Thanks for your comment about problems installing Cypress when Node.js is installed as a snap package https://github.com/nodejs/snap

I can reproduce this problem.

Workaround

npm install cypress -D --ignore-scripts
npx cypress install

Generally, Node.js installed via snap is not flexible enough for use with Cypress as it does not allow a choice of which Node.js version to install. At the moment it installs Node.js 20.14.0 which is almost the LTS version.

zeno-ce commented 3 months ago

@MikeMcC399 Thanks for the workaround, you have some control when installing snaps using their channels. For node there are channels from v6 to latest/edge which is currently 23, but latest stable channel is indeed 20.14. I encountered the problem while using channel 18, which was node 18.20.

MikeMcC399 commented 3 months ago

@zeno-ce

Thanks for filling in my missing know-how on Node.js with snap!

MikeMcC399 commented 3 months ago

Workaround

Workaround - split postinstall phase

npm install cypress -D --ignore-scripts
npx cypress install

Workaround - install Node.js with nvm

Install Node.js on Ubuntu with nvm according to instructions on https://nodejs.org/en/download/package-manager

# installs nvm (Node Version Manager)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

# download and install Node.js (you may need to restart the terminal)
nvm install 20

# verifies the right Node.js version is in the environment
node -v # should print `v20.15.0`

# verifies the right NPM version is in the environment
npm -v # should print `10.7.0`
MikeMcC399 commented 3 months ago

Another workaround for installing Cypress with snap node (+npm) seems to be

npm install cypress -D --foreground-scripts