Getting Permission Denied with sudo npm install (Bitnami / AWS EC2 / NPM) - amazon-web-services

I am using the Bitnami Mean Image to try to host my site on AWS EC2. Once I ssh into my EC2 instance and clone my github repo, I try to run sudo npm install but it won't work. My error message is:
npm ERR! code 1 npm ERR! Command failed: /opt/bitnami/git/bin/git
clone --depth=1 -q -b master
https://github.com/frozeman/bignumber.js-nolookahead.git
/home/bitnami/.npm/_cacache/tmp/git-clone-4966f918 npm ERR!
/home/bitnami/.npm/_cacache/tmp/git-clone-4966f918/.git: Permission
denied npm ERR!
npm ERR! A complete log of this run can be found in: npm ERR!
/home/bitnami/.npm/_logs/2018-02-16T07_07_33_645Z-debug.log

Related

I am not able to install nodemon package

Not able to install nodemon package, here are the error messages.
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules'
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! /Users/atulyadav/.npm/_logs/2021-08-31T18_23_33_532Z-debug.log
(base) atulyadav#ATULs-MacBook-Pro my-express-server %
You can do two things
change the permission of /usr/local/lib/node_modules folder or
Try sudo npm install nodemon - g
Use sudo npm install nodemon -g , this should resolve the issue.
Note : It will prompt you to enter your password, you might not see the "letters" you are typing, but keep on typing and hit enter.

Unable to install nodemon globally through terminal, showing an error

If I give as npm install -g nodemon
getting an error as :
checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules'
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
Please any suggestions.
You need root permissions: try with
sudo npm install -g nodemon
This is a permission error and you can use sudo, But Running sudo npm install (without -g) will create a local directory that can only be altered by the root user. This can really screw things up for you if you try to do npm <something> in the same directory or project later on.
Even sudo npm install -g with a valid installation target can mess things up for you and make it hard to use npm without sudo under some circumstances in the future particularly if you change your npm configuration midstream.
you can use the following steps to update your local OS:
Set your prefix for global installs, e.g. npm config set prefix ~/.npm
Update your PATH to include ~/.npm/bin. For example: echo 'export PATH="$HOME/.npm/bin:$PATH"' >> ~/.zshrc if you’re using zsh.
See Don’t Use sudo with npm for more information.

Elastic Beanstalk EBS NPM Bower install is failing

Having an issue with my EBS deployment. Getting this output everytime it tries to deploy the build.
Application deployment failed at 2018-07-02T02:46:14Z with exit status 1 and error: command npm_install_bower in .ebextensions/bower.config failed.
npm http GET https://registry.npmjs.org/bower
npm http GET https://registry.npmjs.org/bower
npm http GET https://registry.npmjs.org/bower
npm ERR! Error: UNABLE_TO_GET_ISSUER_CERT_LOCALLY
npm ERR! at SecurePair.<anonymous> (tls.js:1430:32)
npm ERR! at SecurePair.emit (events.js:92:17)
npm ERR! at SecurePair.maybeInitFinished (tls.js:1029:10)
npm ERR! at CleartextStream.read [as _read] (tls.js:521:13)
npm ERR! at CleartextStream.Readable.read (_stream_readable.js:341:10)
npm ERR! at EncryptedStream.write [as _write] (tls.js:418:25)
npm ERR! at doWrite (_stream_writable.js:226:10)
npm ERR! at writeOrBuffer (_stream_writable.js:216:5)
npm ERR! at EncryptedStream.Writable.write (_stream_writable.js:183:11)
npm ERR! at write (_stream_readable.js:602:24)
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR! System Linux 4.14.47-56.37.amzn1.x86_64
npm ERR! command "node" "/usr/bin/npm" "install" "-g" "bower"
npm ERR! cwd /opt/elasticbeanstalk/eb_infra
npm ERR! node -v v0.10.48
npm ERR! npm -v 1.3.6
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /opt/elasticbeanstalk/eb_infra/npm-debug.log
npm ERR! not ok code 0.
bower.config file is:
commands:
get_sudo:
command: echo Defaults:root \!requiretty >> /etc/sudoers
npm_install:
command: sudo yum -y --enablerepo=epel install nodejs npm
npm_install_bower:
command: sudo npm install -g bower
container_commands:
01_bower_install:
command: "export PATH=$PATH; $NODE_HOME/bin/node ./node_modules/bowe/bin/bower -V install --allow-root -F > /tmp/01_bower_install.log"
Tried it without 01_bower_install part as well but same result. Fails to deploy. Was working fine until 2 days ago on the instance and now showing:
Forbidden You don't have permission to access / on this server.
..on the URL.
Help greatly appreciated!
I spent few hours today on the same issue, bower would not be installed by npm and would not run. Eventually got it work as follows:
1) remove "bower" from package.json
2) here is my ebextension file that managed to install bower and run it, by making it a global command:
container_commands:
install_bower:
command: "export PATH=$PATH:$NODE_HOME/bin; npm install bower -g; bower install --allow-root"
Cheers,
Z.

Laravel 5.5 API Authentication (Passport) - cross-env: not found error, when i run npm run dev

I have tried to implement laravel passport authentication in my project, but it's not working. Initially, i have installed laravel5.5 with other configuration and file permissions all the stuff.
To implement passport authentication I have followed laravel documentation Document Url
Following steps, I have done,
composer require laravel/passport
php artisan migrate
php artisan passport:install
I have added this line App\User
use Laravel\Passport\HasApiTokens;
use HasApiTokens, Notifiable;
Routes Added in AuthServiceProvider file inside the boot function
Passport::routes();
Inside the config/auth.php file, I have changed API driver as passport
php artisan vendor:publish --tag=passport-components
Inside this file resources/assets/js/app.js
Vue.component(
'passport-clients',
require('./components/passport/Clients.vue')
);
Vue.component(
'passport-authorized-clients',
require('./components/passport/AuthorizedClients.vue')
);
Vue.component(
'passport-personal-access-tokens',
require('./components/passport/PersonalAccessTokens.vue')
);
npm run dev
When running this command I'm getting an error
$ npm run dev
# dev /var/www/html/local/laravel5.5
npm run development
# development /var/www/html/local/laravel5.5
cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
sh: 1: cross-env: not found
npm ERR! Linux 4.4.0-98-generic
npm ERR! argv "/home/sysadmin/.nvm/versions/node/v6.11.1/bin/node" "/home/sysadmin/.nvm/versions/node/v6.11.1/bin/npm" "run" "development"
npm ERR! node v6.11.1
npm ERR! npm v3.10.10
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! # development: cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the # development script 'cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! Please include the following file with any support request:
npm ERR! /var/www/html/local/laravel5.5/npm-debug.log
npm ERR! Linux 4.4.0-98-generic
npm ERR! argv "/home/sysadmin/.nvm/versions/node/v6.11.1/bin/node" "/home/sysadmin/.nvm/versions/node/v6.11.1/bin/npm" "run" "dev"
npm ERR! node v6.11.1
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! # dev: npm run development
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # dev script 'npm run development'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! npm run development
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls
npm ERR! There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! Please include the following file with any support request:
npm ERR! /var/www/html/local/laravel5.5/npm-debug.log
You must run in cmd/terminal, from your project folder
npm install --save
and then
npm run dev

Trouble setting up a Loopback production host on AWS EC2

I'm having trouble setting up a StrongLoop LoopBack production host on AWS EC2. I'm following these directions.
This is what I tried. I created an EC2 server that's a Ubuntu Server 14.04 LTS. Then I:
$ ssh -i ~/mykey.pem ubuntu#[ec2-ip-address]
$ sudo apt-get update
$ sudo apt-get install build-essential
$ curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash
$ nvm install v0.12.4
$ nvm alias default 0.12.4
$ npm install -g strong-pm
$ sudo sl-pm-install
sudo: sl-pm-install: command not found
$ sl-pm-install
Error adding user strong-pm:
useradd: Permission denied.
useradd: cannot lock /etc/passwd; try again later.
Error installing service 'undefined': Command failed: /usr/sbin/useradd --home /var/lib/strong-pm --shell /bin/false --skel /dev/null --create-home --user-group --system strong-pm
useradd: Permission denied.
useradd: cannot lock /etc/passwd; try again later.
As you can see, I cannot install the standalone StrongLoop Process Manager module as "ubuntu" or by using "sudo." This made me wonder if I should be installing everything as root, but I ran into trouble with this approach as well:
$ sudo su
# curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash
# nvm install v0.12.4
# nvm alias default 0.12.4
When tring to install the standalone StrongLoop Process Manager module as root, I got the following error:
# npm install -g strong-pm
> heapdump#0.3.5 install /root/.nvm/versions/node/v0.12.4/lib/node_modules/strong-pm/node_modules/strong-runner/node_modules/strong-supervisor/node_modules/heapdump
> node-gyp rebuild
sh: 1: node-gyp: Permission denied
npm WARN optional dep failed, continuing heapdump#0.3.5
> strong-fork-syslog#1.2.3 install /root/.nvm/versions/node/v0.12.4/lib/node_modules/strong-pm/node_modules/strong-runner/node_modules/strong-supervisor/node_modules/strong-fork-syslog
> node-gyp rebuild
sh: 1: node-gyp: Permission denied
npm WARN optional dep failed, continuing strong-fork-syslog#1.2.3
> strong-agent#1.5.1 install /root/.nvm/versions/node/v0.12.4/lib/node_modules/strong-pm/node_modules/strong-runner/node_modules/strong-supervisor/node_modules/strong-agent
> node-gyp rebuild || exit 0
sh: 1: node-gyp: Permission denied
/
> sqlite3#3.0.8 install /root/.nvm/versions/node/v0.12.4/lib/node_modules/strong-pm/node_modules/strong-mesh-models/node_modules/minkelite/node_modules/sqlite3
> node-pre-gyp install --fallback-to-build
sh: 1: node-pre-gyp: Permission denied
npm ERR! Linux 3.13.0-48-generic
npm ERR! argv "/root/.nvm/versions/node/v0.12.4/bin/node" "/root/.nvm/versions/node/v0.12.4/bin/npm" "install" "-g" "strong-pm"
npm ERR! node v0.12.4
npm ERR! npm v2.10.1
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! sqlite3#3.0.8 install: `node-pre-gyp install --fallback-to-build`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the sqlite3#3.0.8 install script 'node-pre-gyp install --fallback-to-build'.
npm ERR! This is most likely a problem with the sqlite3 package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install --fallback-to-build
npm ERR! You can get their info via:
npm ERR! npm owner ls sqlite3
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/ubuntu/npm-debug.log
What's a proper way to set up a StrongLoop LoopBack production host on AWS EC2? How's it done?
You can install NodeJS from a PPA using the following commands as documented in this blog post:
$ curl -sL https://deb.nodesource.com/setup_0.12 | sudo bash -
$ sudo apt-get install -y nodejs
The other ideas suggested in the comments also have potential. However, this was the one I was able to get working easily.