Failed to install puppeteer using npm - connect EACCES - npm

When I try to run a npm install, it fails at a dependency called puppeteer.
And if I run:
npm install -g puppeteer#1.5.0
(existing in package.json as "puppeteer": "1.5.0",) it fails with the following error:
npm ERR! code EACCES
npm ERR! errno EACCES
npm ERR! FetchError: request to http://registry.npmjs.org/puppeteer failed, reason: connect EACCES 104.16.27.35:80
npm ERR! at ClientRequest.req.on.err (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
npm ERR! at ClientRequest.emit (events.js:182:13)
npm ERR! at Socket.socketErrorListener (_http_client.js:391:9)
npm ERR! at Socket.emit (events.js:182:13)
npm ERR! at emitErrorNT (internal/streams/destroy.js:82:8)
npm ERR! at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
npm ERR! at process._tickCallback (internal/process/next_tick.js:63:19)
but I can access that URL (http://registry.npmjs.org/puppeteer) using my browser.
The other dependencies specified in package.json work fine. Only this one generates problems.
Details:
npm - 6.2.0
node - v10.9.0
OS: Windows
Any suggestions?

npm ERR! code EACCES
npm ERR! errno EACCES
This is a permission error, on a normal day, I will say you should just use sudo npm install -g puppeteer#1.5.0, but I will suggest you reclaim ownership of the .npm directory by running this:
sudo chown -R $(whoami) ~/.npm
Then you need the write permission in node_modules directory:
sudo chown -R $(whoami) /usr/lib/node_modules
after which you can run your npm install -g puppeteer#1.5.0, This should solve your issue.
UPDATE:
I will suggest two other options for you,
from your terminal, run this:
npm config set unsafe-perm=true
OR
use yarn add for your installation.

also sometimes it just takes a while; I used npm install (I'm trying to use formkit but I'm not sure if it matters) --verbose and I'm getting a bunch of
npm http fetch GET 200 https://registry.npmjs.org/#formkit%2fvalidation
70085ms (cache stale)
so I assume its some issue that requires me to download things that take a very long time. Maybe an issue connecting to the verification server?
Edit: restarted computer, cleared cache, etc etc. Still weird and slow.
Not sure what happened but fixed it by going into my IDE (Jetbrains WebStorm) and changing my package handler in settings to a different nodejs. The one I was using was in Program Files and was having trouble accessing pieces in AppData/Roaming, There was another installation inside AppData and picking that one automatically solved my permissions issue.

Related

How to update npm in Laravel Sail

I am currently using Laravel 8.48.2 with the Sail package. I set Sail up and running its image through Docker Desktop while using WSL 2 with a Ubuntu distro on Windows. All seems to be working fine.
After I ran sail npm install, the packages were installed successfully, but I received the following message:
npm notice New minor version of npm available! 7.18.1 -> 7.19.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v7.19.0
npm notice Run npm install -g npm#7.19.0 to update!
Therefore, I tried running sail npm install -g npm#7.19.0 which gave me the following message:
npm ERR! code EACCES
npm ERR! syscall rename
npm ERR! path /usr/lib/node_modules/npm
npm ERR! dest /usr/lib/node_modules/.npm-qUIFSsiV
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm-qUIFSsiV'
npm ERR! [Error: EACCES: permission denied, rename '/usr/lib/node_modules/npm' -> '/usr/lib/node_modules/.npm-qUIFSsiV'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'rename',
npm ERR! path: '/usr/lib/node_modules/npm',
npm ERR! dest: '/usr/lib/node_modules/.npm-qUIFSsiV'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/sail/.npm/_logs/2021-06-26T15_27_02_291Z-debug.log
How can I update the NPM version on Sail?
Thank you in advance.
Current working method:
sail root-shell
npm install -g npm#latest
Looking at your log it seems the user you run as has insufficient permission on the folder /usr/lib/node_modules/. So what you might try is to log in to the container with docker-compose exec laravel.test bash and use chown -R user:group /usr/lib/node_modules/ with the current user and group (found by whoami). Or chmod the folder to have more looser permission overall on this folder.
Thanks to #online Thomas (https://stackoverflow.com/a/68173952/14508436), in order to resolve my issue, I followed these steps:
Within my Laravel project's directory, I ran this command... docker-compose exec laravel.test bash, which points you to the docker's server (or something like that), directly on your project's directory.
I ran this command... npm install -g npm#7.19.0 which updated npm to a newer version without any issues.
I tried the chown and chmod commands as suggested by #online Thomas, but in vain. I still couldn't use the sail npm install -g npm#7.19.0 command outside of the docker's server.

Missing write access error on nativescript install

When I attempt to install nativescrtipt by running npm i -g nativescript, I receive the following error:
npm WARN checkPermissions Missing write access to
/usr/local/lib/node_modules/nativescript
npm ERR! path /usr/local/lib/node_modules/nativescript
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall access
npm ERR! enoent ENOENT: no such file or directory, access
'/usr/local/lib/node_modules/nativescript'
npm ERR! enoent This is related to npm not being able to find a
file.
I have tried to run the command as sudo and receive the same result. I also attempted to add write permission to the node_modules directory.
I am running node v10.6.0 on macOS High Sierra.
Add sudo command to allow you run the program with security privilege
sudo npm i -g nativescript
I followed this link: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally to resolve the issue.
I installed nvm and updated to the latest version of node. Then, the command npm i -g nativescript successfully installed the nativescript-cli.
The issue does not appear to be coming from nativescript, but an issue with my node installation.
Run the following command sudo npm i -g nativescript
This will forcefully with security permission install the missing scripts to run the npm command again with no bugs or warnings

How to install mfpdev-cli to offline environment?

I am trying to setup offline (does not have internet access) OS X machine for MobileFirst Platform 8.0 development, and failing to install MobileFirst CLI.
I am referring to this article.
I have installed 8.0.0.0-MFPF-DevKit-MacOSX-IF2016080923.zip on the offline machine, then run.sh and console.sh.
Development server has successfully launched, and now I can access to Operations Console.
I have downloaded mfpdev-cli.tar from the Console, and followed the article I cited above.
Copy mfpdev-cli.tar to online machine.
On the online machine, npm --cache ./.cache install mfpdev-cli.tar
Archive .cache directory, and copy the archive file to the offline machine.
On the offline machine, unarchive .cache directory.
sudo npm install --cache ./.cache ./mfpdev-cli.tar -g
Then, I got below:
npm ERR! fetch failed https://registry.npmjs.org/http-proxy/-/http-proxy-1.13.2.tgz
npm WARN retry will retry, error on last attempt: Error: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
Those ERR! and WARN repeats for many other packages.
And at last:
npm ERR! Darwin 15.6.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--cache" "./.cache" "./mfpdev-cli.tar" "-g"
npm ERR! node v4.5.0
npm ERR! npm v2.15.9
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! syscall getaddrinfo
npm ERR! network getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm ERR! network This is most likely not a problem with npm itself
npm ERR! network and is related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! Please include the following file with any support request:
npm ERR! /Users/babatch/Downloads/mfpdev-cli/npm-debug.log
How do I install mfpdev-cli on offline machine?
The problem is that npm is attempting to contact its online repository still due to some file dependency on the http-proxy package.
What you can do is to get/add this dependency independently and then try again.
I have tried some methods, and finally it got working.
The procedure is below:
On the online machine, npm install ./mfpdev-cli.tar (without -g)
cd node_modules
tar -cvzf mfpdev-cli.tgz mfpdev-cli and copy mfpdev-cli.tgz just created to the offline machine.
On the offline machine, tar -xvzf mfpdev-cli.tgz
sudo cp -r mfpdev-cli /usr/local/lib/node_modules
cd /usr/local/bin
sudo ln -s ../lib/node_modules/mfpdev-cli/bin/cli.js ./mfpdev
At present, it seems to be working fine.

How to Fix Error "user admin is not allowed to access package"

I am updated now and running
node v5.0.0
npm v3.3.6
On a Mac (El Capitan)
When i run "npm install" on my project now. I get errors like this:
me:controls me$ sudo npm install
npm ERR! Darwin 15.0.0
npm ERR! argv "/usr/local/Cellar/node/0.10.36/bin/node" "/usr/local/bin/npm" "install"
npm ERR! node v5.0.0
npm ERR! npm v3.3.6
npm ERR! code E403
npm ERR! user admin is not allowed to access package chai : chai
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /Users/me/Dev/controls/npm-debug.log
Im not seeing any solutions to this around the web yet? I tried both sudo and not sudo and makes no difference.
Any suggestions?
I had the same problem. Check the registry: npm config list.
Try to run:
npm set registry "https://registry.npmjs.org/"
and then npm i again.
I used sinopia as a registry. Sinopia can't work with scoped packages.

CastMyCode installation error

I try to install CastMyCode on my machine using this command: npm install -g castmycode
Unfortunately, I got this error message:
npm WARN locking Error: EACCES, open '/Users/zulhilmizainudin/.npm/_locks/castmycode-603889af8ee0127d.lock'
npm WARN locking at Error (native)
npm WARN locking /Users/zulhilmizainudin/.npm/_locks/castmycode-603889af8ee0127d.lock failed { [Error: EACCES, open '/Users/zulhilmizainudin/.npm/_locks/castmycode-603889af8ee0127d.lock']
npm WARN locking errno: -13,
npm WARN locking code: 'EACCES',
npm WARN locking path: '/Users/zulhilmizainudin/.npm/_locks/castmycode-603889af8ee0127d.lock' }
npm ERR! Darwin 14.1.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "castmycode"
npm ERR! node v0.12.0
npm ERR! npm v2.6.1
npm ERR! Attempt to unlock /usr/local/lib/node_modules/castmycode, which hasn't been locked
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <http://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /Users/zulhilmizainudin/npm-debug.log
I'm using NPM v2.6.1.
Btw, for those of you that don't know what CastMyCode is, it's actually a simple web app that allow anybody to share their codes and let others view their codes.
It's built by one of my friend. If you're programming mentor/lecturer, CastMyCode can help your students see all your codes changes right inside their web browsers.
Solved. I run this 2 commands inside my terminal:
sudo chown -R $USER ~/.npm
sudo chown -R $USER /usr/local/lib/node_modules
Then I run this command:
npm install -g castmycode
CastMyCode now successfully installed & I can use it. Thanks IBam for sharing the solution!