Unable to install nodemon globally through terminal, showing an error - nodemon

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.

Related

windows 10 -'bash' is not recognized as an internal or external command, operable program or batch file [duplicate]

i have an error in installing react-flux-starter-kit-windows.
i have installed latest node.js and npm
when i am using this command :
npm install -g react-flux-starter-kit
it gives me following error
react-flux-starter-kit#1.1.4 postinstall C:\Users\Hardik\AppData\Roaming\npm\node_modules\react-flux-starter-kit
bash setup.sh
'bash' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\Program Files\nodejs\node.exe" "C:\Users\Hardik\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "install" "-g" "react-flux-starter-kit"
npm ERR! node v6.9.5
npm ERR! npm v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-flux-starter-kit#1.1.4 postinstall: bash setup.sh
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-flux-starter-kit#1.1.4 postinstall script 'bash setup.sh'.
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 react-flux-starter-kit package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! bash setup.sh
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs react-flux-starter-kit
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls react-flux-starter-kit
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\Hardik\AppData\Roaming\npm-cache_logs\2017-02-22T10_01_48_356Z-debug.log
It seems that it needs Bash installed. If you're using Windows then you may be able to install it using one of:
https://git-for-windows.github.io/
https://www.cygwin.com/
https://msdn.microsoft.com/en-us/commandline/wsl/about
http://win-bash.sourceforge.net/
Go with the steps
Setting->update->for developers->developers mood->on->yes.
Control Panel->programs & features->Turn windows features on or off->Windows subsystem for linux->restart computer.
The same error can appear if the bash isn't present in path env, so you need to add it manually.
Add this directory to your path env:
C:\Program Files\Git\bin
I had the same problem and I solved it in 2 stages:
First, I turned on the 'Developer Mode' (Settings -> Update and Security -> For developers).
Second, I installed Ubuntu app from Microsoft Store, then ran Command Prompt as administrator and typed bash and set a username and password.
To fix this on Windows, if you install git for windows you will get git.exe at this directory:
C:\Program Files\Git\cmd
but the file is git.exe and you need bash.exe for Windows.
So use this to create a doskey alias to bash command
doskey bash=git
Now type bash at command line and you should see the help output from git.exe.
If you're using Windows then you may be able to use GIT Bash which you probably already have it installed or get it from https://gitforwindows.org/ instead of using Windows Command Prompt or Windows PowerShell.

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.

AWS-Amplify-cli fails to install on Mac

Trying to install AWS-Amplify-CLI and followed this
When I run npm install -g #aws-amplify/cli or sudo npm install -g #aws-amplify/cli I get the following errors
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Pre-built binaries not installable for fsevents#1.2.7 and node#11.8.0 (node-v67 ABI, unknown) (falling back to source compile with node-gyp)
node-pre-gyp WARN Hit error EACCES: permission denied, mkdir '/usr/local/lib/node_modules/node/lib/node_modules/#aws-amplify/cli/node_modules/fsevents/lib'
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/node/lib/node_modules/#aws-amplify/cli/node_modules/fsevents/build'
gyp ERR! System Darwin 18.2.0
gyp ERR! command "/usr/local/lib/node_modules/node/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "--fallback-to-build" "--module=/usr/local/lib/node_modules/node/lib/node_modules/#aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node" "--module_name=fse" "--module_path=/usr/local/lib/node_modules/node/lib/node_modules/#aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64" "--napi_version=4" "--node_abi_napi=napi"
gyp ERR! cwd /usr/local/lib/node_modules/node/lib/node_modules/#aws-amplify/cli/node_modules/fsevents
gyp ERR! node -v v11.8.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute '/usr/local/lib/node_modules/node/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/node/lib/node_modules/#aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/node/lib/node_modules/#aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64 --napi_version=4 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack at ChildProcess. (/usr/local/lib/node_modules/node/lib/node_modules/#aws-amplify/cli/node_modules/fsevents/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:197:13)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:978:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:265:5)
node-pre-gyp ERR! System Darwin 18.2.0
node-pre-gyp ERR! command "/usr/local/lib/node_modules/node/bin/node" "/usr/local/lib/node_modules/node/lib/node_modules/#aws-amplify/cli/node_modules/fsevents/node_modules/node-pre-gyp/bin/node-pre-gyp" "install" "--fallback-to-build"
node-pre-gyp ERR! cwd /usr/local/lib/node_modules/node/lib/node_modules/#aws-amplify/cli/node_modules/fsevents
node-pre-gyp ERR! node -v v11.8.0
node-pre-gyp ERR! node-pre-gyp -v v0.10.3
node-pre-gyp ERR! not ok
Failed to execute '/usr/local/lib/node_modules/node/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js configure --fallback-to-build --module=/usr/local/lib/node_modules/node/lib/node_modules/#aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64/fse.node --module_name=fse --module_path=/usr/local/lib/node_modules/node/lib/node_modules/#aws-amplify/cli/node_modules/fsevents/lib/binding/Release/node-v67-darwin-x64 --napi_version=4 --node_abi_napi=napi' (1)
npm WARN graphql-import#0.4.5 requires a peer of graphql#^0.11.0 || ^0.12.0 || ^0.13.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.7 (node_modules/#aws-amplify/cli/node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.7 install: node install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
#aws-amplify/cli#0.1.44
added 2 packages from 1 contributor, removed 6 packages and updated 29 packages in 57.461s
When I install node-pre-gyp and node-gyp separately, I get the same errors.
I have CHMOD 0777 on the project folder and then tried to install again without the -g flag, but same error.
OS: Mojave 10.14.2
Node: v11.8.0
npm: 6.5.0
You may also try the following command that worked for me :
sudo npm install -g #aws-amplify/cli --unsafe-perm=true
Fixed.
It seems that there was an issue with my global installation of node and npm, missing/incorrect entries in:
~/.bash_profile
~/.bashrc
The fix was to totally remove node & npm, the re-install using nvm. I followed these:
https://github.com/brock/node-reinstall/
https://gist.github.com/d2s/372b5943bce17b964a79
Please note:
you may need to remove some node or npm files manually
you may need to upgrade node and/or npm afterwards
you may need to reinstall individual node packages afterwards.
I had a similar issue. I needed to set the python version for some odd reason. Something like
npm config set python python2.7 && npm install
Amplify needs local resources and needs to be tied to a environment especially if you are switching between them.
Like dev/prod or local dev on a Mac vs some dev in windows.
Look at amplify env add
I had node installed via brew so my fix was:
uninstall node completely
brew uninstall --force node
install node via: https://nodejs.org/es/ which updates PATH automatically
install amplify:
sudo npm install -g #aws-amplify/cli --unsafe-perm=true
This is what I did to solve this:
Re-install node to the latest version. You can do that using the following steps:
- sudo npm cache clean -f (force) clear you npm cache
- sudo npm install -g n install n (this might take a while)
- sudo n stable upgrade to the current stable version
Note that sudo might prompt your password.
Install amplify:
sudo npm install -g #aws-amplify/cli --unsafe-perm=true
This last process may take a while.
EACCES permissions errors when installing packages globally
First uninstall amplify
npm uninstall -g #aws-amplify/cli
or
sudo amplify uninstall
Reinstall npm with a node version manager, I recommend this guide https://tecadmin.net/install-nvm-macos-with-homebrew/
On command line create a directory for global installations
mkdir ~/.npm-global
Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
For versions after MacOS Catalina uses nano ~/.zshrc and for versions before this version uses nano ~/.profile and add the next line
export PATH=~/.npm-global/bin:$PATH
On the command line, update your system variables. If you used ~/. zshrc
source ~/.zshrc
If you used ~/. profile
source ~/.profile
Then try to install amplify
npm install -g #aws-amplify/cli
While the accepted solution seemed to work initially, I encountered further EACCES: permission error while using amplify-cli. The way I got it solved is by resolving EACESS permissions as recommended by npmjs documentation.
Instructions:
On the command line, in your home directory, create a directory for global installations:
mkdir ~/.npm-global
Configure npm to use the new directory path:
npm config set prefix '~/.npm-global'
In your preferred text editor, open or create a ~/.profile file and add this line:
nano ~/.profile
export PATH=~/.npm-global/bin:$PATH
On the command line, update your system variables:
source ~/.profile
Test if the added path is working by looking for the string .npm-global/bin in the outpout:
echo $PATH
Finally, install aws-amplify/cli without using sudo as follows:
npm install -g #aws-amplify/cli

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