AWS Beanstalk -> "unsafe-perm=true" in .npmrc file for AWS Beanstalk not working - express

Hi there I am using AWS Beanstalk to deploy my Express app for the first time right and when I try to upload my Express app I get an error saying this:
[ERROR] An error occurred during execution of command [app-deploy] - [Use NPM to install dependencies]. Stop running the command. Error: Command /bin/sh -c npm --production install failed with error exit status 1. Stderr:npm ERR! code 1
npm ERR! path /var/app/staging/node_modules/sharp
npm ERR! command failed
npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
npm ERR! sharp: Are you trying to install as a root or sudo user? Try again with the --unsafe-perm flag
npm ERR! sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies
npm ERR! sharp: Installation error: EACCES: permission denied, mkdir '/root/.npm'
I know that the solution was to add .npmrc with code unsafe-perm=true but this didnt fix the issue. It seems that the issue is on the user that is use to perform the installation of dependencies and node-gyp may need root privilegies.
Any idea how to achieve this? It failes as soon as it tries to install the 'sharp' library

Related

Eror occurs when install nuxt and create app

Cannot instal nuxt and create app.
I used https://nuxtjs.org/docs/get-started/installation and https://github.com/nuxt/create-nuxt-app for creating app but this error occurs:
"create-nuxt-app"
is not internal or external
command executed by a program or batch file.
npm ERR! path C:\Users\Acer\Desktop\nuxt
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c create-nuxt-app "hacker-news"
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Acer\AppData\Local\npm-cache\_logs\2022-12-03T06_03_59_129Z-debug-0.log```
Please help!
PS: node js and npm are installed
Figured it out.
npm cache clean --force (sudo if needed)
npm install

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.

Vue CLI error creating new project (npm error)

Please help me on this. I can't create a new Vue CLI project. It previously works good! Now not working...
Vue CLI v4.2.3
✨ Creating project in /Web develop/Vue Projects/new.
🗃 Initializing git repository...
⚙️ Installing CLI plugins. This might take a while...
npm ERR! Unexpected end of JSON input while parsing near '...loader":"~0.8.0","js-'
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/Malaka/.npm/_logs/2020-03-25T06_30_10_474Z-debug.log
ERROR command failed: npm install --loglevel error
seems a cache error
run
npm cache clean --force
then try create the project again
That's weird. I'd just try re-installing the Vue cli package.
There is a deprecated vue-cli package, it could be you have that installed rather than the official one #vue/cli.
Either way just uninstall it with
npm uninstall [your-vue-cli-package] -g
Then re-install it again.
npm install #vue/cli -g
lets try this
$ sudo npm uninstall -g vue
$ sudo npm uninstall -g vue-cli
$ sudo npm uninstall -g #vue/cli
$ sudo npm cache clean --force
$ sudo npm install -g vue
$ sudo npm install -g #vue/cli
problem log:
npm ERR! code ERR_SOCKET_TIMEOUT
npm ERR! network Socket timeout
npm ERR! network This is a problem 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! A complete log of this run can be found in:
npm ERR! C:\Users\DraKoan\AppData\Local\npm-cache\_logs\2022-04-19T17_09_34_388Z-debug-0.log
ERROR Error: command failed: npm install --loglevel error --legacy-peer-deps
Error: command failed: npm install --loglevel error --legacy-peer-deps
at ChildProcess.<anonymous> (C:\Users\DraKoan\AppData\Roaming\npm\node_modules\#vue\cli\lib\util\executeCommand.js:138:16)
at ChildProcess.emit (node:events:526:28)
at ChildProcess.cp.emit (C:\Users\DraKoan\AppData\Roaming\npm\node_modules\#vue\cli\node_modules\cross-spawn\lib\enoent.js:34:29)
at maybeClose (node:internal/child_process:1092:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
Solve:
check proxy at config
npm config edit
npm config --global edit
clean and set proxy
npm config set proxy null
npm config set proxy false

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

Failed to install puppeteer using npm - connect EACCES

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.