Npm ci showing error

I was trying to set up p5.js locally but npm ci is failing.

It says:
error path /home/sagar/Desktop/processing/p5.js/node_modules/puppeteer
error command failed
error command sh -c node install.js

I have attached the ss and log of npm ci.

I have no idea of how to fix this, please help

0 verbose cli [ '/snap/node/3717/bin/node', '/usr/local/bin/npm', 'ci' ]
1 info using npm@7.5.3
2 info using node@v14.15.5
3 timing config:load:defaults Completed in 4ms
4 timing config:load:file:/usr/local/lib/node_modules/npm/npmrc Completed in 5ms
5 timing config:load:builtin Completed in 6ms
6 timing config:load:cli Completed in 3ms
7 timing config:load:env Completed in 1ms
8 timing config:load:file:/home/sagar/Desktop/processing/p5.js/.npmrc Completed in 0ms
9 timing config:load:project Completed in 1ms
10 timing config:load:file:/home/sagar/.npmrc Completed in 1ms
11 timing config:load:user Completed in 1ms
12 timing config:load:file:/etc/npmrc Completed in 0ms
13 timing config:load:global Completed in 0ms
14 timing config:load:cafile Completed in 0ms
15 timing config:load:validate Completed in 0ms
16 timing config:load:setUserAgent Completed in 1ms
17 timing config:load:setEnvs Completed in 2ms
18 timing config:load Completed in 19ms
19 verbose npm-session 301839525efcfcab
20 timing npm:load Completed in 32ms
.
.
.
.
.
2600 timing metavuln:load:security-advisory:grunt-contrib-yuidoc:4UIcCkM/rH4uzwuBV9pFCfqubjb3hkmK//vDFKjfOFKhVcAIli1sXhE1UGaMYu5qwM8B0GsqrOMq108EvlZ7Og== Completed in 0ms
2601 timing metavuln:calculate:security-advisory:grunt-contrib-yuidoc:4UIcCkM/rH4uzwuBV9pFCfqubjb3hkmK//vDFKjfOFKhVcAIli1sXhE1UGaMYu5qwM8B0GsqrOMq108EvlZ7Og== Completed in 341ms
2602 timing metavuln:cache:get:security-advisory:np:uWxxQvgoO0PZfExv+vm290hgxbZ6MlSdulo4tPl9yhkJuhPWTtkgQsbmG+AzVEO/T23wXgq1Fqey3xnbTazb3A== Completed in 34ms
2603 timing metavuln:load:security-advisory:np:bv1OvUNUlwp9g4gPV9mVc8e74E0ehGKayMlwOMYhk/Q9Z6SIPOOAu3+l9XPo1nMwOWCQo9OYhC5CG/aCHHCNYg== Completed in 1ms
2604 timing metavuln:calculate:security-advisory:np:bv1OvUNUlwp9g4gPV9mVc8e74E0ehGKayMlwOMYhk/Q9Z6SIPOOAu3+l9XPo1nMwOWCQo9OYhC5CG/aCHHCNYg== Completed in 35ms
2605 timing auditReport:init Completed in 78344ms
2606 timing reify:audit Completed in 91789ms
2607 info run puppeteer@5.5.0 install { code: 1, signal: null }
2608 timing reify:rollback:createSparse Completed in 6325ms
2609 timing reify:rollback:retireShallow Completed in 0ms
2610 timing command:ci Completed in 180347ms
2611 verbose stack Error: command failed
2611 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
2611 verbose stack     at ChildProcess.emit (events.js:315:20)
2611 verbose stack     at maybeClose (internal/child_process.js:1048:16)
2611 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
2612 verbose pkgid puppeteer@5.5.0
2613 verbose cwd /home/sagar/Desktop/processing/p5.js
2614 verbose Linux 5.0.0-37-generic
2615 verbose argv "/snap/node/3717/bin/node" "/usr/local/bin/npm" "ci"
2616 verbose node v14.15.5
2617 verbose npm  v7.5.3
2618 error code 1
2619 error path /home/sagar/Desktop/processing/p5.js/node_modules/puppeteer
2620 error command failed
2621 error command sh -c node install.js
2622 verbose exit 1

Hi,

Welcome to the forum! :wink:

From what I see, this is the error :

error path /home/sagar/Desktop/processing/p5.js/node_modules/puppeteer

Looks like the package has not been installed correctly.

Maybe you can try doing the following :

# Delete all the installed packages
rm -rf node_modules/

# Install packages
npm install

Instead of using npm ci, you can try using npm install and it will do the same thing approximately

Hi,

we already mentioned this issue on this forum couple months ago : Fatal error: Protocol error (Runtime.callFunctionOn): Object reference chain is too long

I’ve opened a ticket on Github, but it will be fixed in some time because contributors have a lot to do.
From what I saw, it is because you’re using a old npm version, and you should update it. New versions don’t provoke blocking issue for this.

1 Like

@josephh i am still getting the same error with npm install. There is some problem with the installation of puppeteer. Even if i simply do npm i puppeteer , installation fails with the same error message:

error path ....../node_modules/puppeteer
error command failed
error command sh -c node install.js

@Pr0tonX i am already using the latest stable versions of node and npm.

I think the issue you mentioned is different from this issue. The issue you mentioned occurs while running grunt. But i am still stuck at installing dependencies

1 Like

Ok so from this link can you run :

npm install puppeteer --ignore-scripts

then do :

npm ci

npm install puppeteer --ignore-script works
but npm ci fails
same error again

All right, are you sure that this path is valid?

ls /home/sagar/Desktop/processing/p5.js/node_modules/puppeteer

If so you go inside the puppeteer folder and do :

sh -c node install.js

What is the output?

If there’s still an error, try to open an issue on their GitHub repo : here

1 Like

yes

Its opening node shell instead of downloading chromium
maybe because of this whenever i do npm ci or npm install it works fine until it executes sh -c node install.js and as soon as it starts executing sh -c node install.js it gets stuck for 2-3 minutes and then maybe times out and throws error.
However If i type node install.js inside the puppeteer folder then its downloading chromium

So the problem is sh -c node install.js opens a node shell instead of downloading chromium.
If i am not wrong should i open an issue on their github repo or can there be any other possible workaround through which i will be able to set up p5.js ?

Yes you are right, it seems that node doesn’t understand the last parameter but it’s strange because the man sh page tells :

-c Read commands from the command_string operand instead of from the
standard input. Special parameter 0 will be set from the
command_name operand and the positional parameters ($1, $2, etc.)
set from the remaining argument operands.

This is the same with :

$ sh -c python3 test.py      
Python 3.8.6 (default, Sep 25 2020, 09:36:53) 
[GCC 10.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

even if test.py doesn’t exist.

I think that Grunt is calling the sh -c node install.js command because in a test project I can easily install puppeteer without problem :

mkdir test && cd test
npm init -y
npm install puppeteer

Try posting an issue on the p5 GitHub repo instead :wink:

2 Likes

Maybe you can try to install a specific version of puppeeter by mentionning it (here the last one) :

npm i puppeteer@1.18.1

or the prerelease version of puppeeter instead of the one used by p5.js which contains at least one bug :

npm i --save puppeteer@next
1 Like

I did not understand this part
I looked into gruntfile.js but i was not able to find anything related to sh -c node install.js
Also in the file .../node_modules/puppeteer/install.js it is mentioned that:

By default, the puppeteer package runs this script during the installation
process unless one of the env flags is provided.

So I think puppeteer is calling sh -c node install.js and issue should be posted on puppeteer’s repo. I may be wrong because I dont know much about grunt or what exactly happens internally when we execute npm install package_name :sweat_smile: So please cocrrect me if i am wrong.

I am not sure because as I said you can create a test project and install puppeteer with npm install puppeteer and it works fine.

I tried doing npm ci with the latest commit on the main branch (Fri Feb 12 14:25:50 2021, make sure to do git pull) and there’s no errors :

~/p5.js $ npm ci

added 1889 packages, and audited 1890 packages in 53s

33 vulnerabilities (13 low, 10 moderate, 10 high)

To address issues that do not require attention, run:
  npm audit fix

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.

So make sure to pull the latest commit and if it doesn’t work then there’s an issue with your configuration or something.

I also noticed that you installed Node as a snap package, maybe it’s causing issues.

2 Likes

Grunt is a task runner for JS but I don’t think it is involved here ; we even don’t reach the step where you run npm run gruntt.
The puppeteer package does not suffer any troubles in itself indeed because you can run it easily alone.
But I guess that sh - c node install.js is simply the “translation” of the running task of npm.
The weird thing is that the command isn’t a string, so of course it opens a Node terminal session, and do not install anything (you can try sh -c 'node install.js' to see the normal expected behavior).

However, the point mentioned by @josephh is interesting : if you downloaded npm & node via snap, you might try to download the binary from the official website of Node.js, and then try to reinstall the P5 project.

I didn’t find anything like this in my files, cloned from the latest release of the p5 repo (1.1.9 so far), which version do you have ? (you can find it in the package.json)

2 Likes

Ah interesting!! That’s what I was searching for and I didn’t understand why it didn’t work without the quotes :wink:

To test if the snap installation is really a problem, you can try running :

which node
whereis node

# Does this works?
sh -c node

Otherwise install it with apt with sudo apt install nodejs (better than snap in my opinion) or from their website as mentioned by @Pr0tonX

2 Likes

Okay I will install nodejs using apt or from nodejs site and then will post the findings here.

Its not in cloned files. When i run npm ci or lets say just npm i puppeteer then first puppeteer package files are downloaded inside node_modules/puppeteer , one of those files is install.js (which installs a recent version of chromium ). If you open this install.js file you will see it has the code to download browser and also in the comments its mentioned that this (install.js) script is run by puppeteer itself.

But as pointed by you guys command sh -c node install.js is not working as expected irrespective of whether puppeteer calls it or p5.
So i will check if this strange behaviour is due to snap installation of nodejs.

I removed nodejs from snap store and then installed nodejs again from node’s distributions page in github. Now npm ci is working properly.
Thank a lot @josephh and @Pr0tonX for helping with this issue :smiley:

2 Likes

Nice then !
Interesting insight anyway, you might open a ticket on the snapstore for the nodejs package !

2 Likes