Vsts Build Please Try Running This Command Again as Root/administrator.

I found this fault when creating a jhipster projection with npm, and first trying to install the node generator-jhipster library with:

          npm install -g generator-jhipster                  

The error detail is every bit follows:

          [operatorfeitam@dev01 client01-app-project]$ npm install -g generator-jhipster npm WARN deprecated request@2.88.2: request has been deprecated, come across https://github.com/asking/request/issues/3142 npm WARN deprecated har-validator@v.i.5: this library is no longer supported npm ERR! path /usr/local/bin/jhipster npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall unlink npm ERR! Error: EACCES: permission denied, unlink '/usr/local/bin/jhipster' npm ERR!  { [Error: EACCES: permission denied, unlink '/usr/local/bin/jhipster'] npm ERR!   cause: npm ERR!    { Error: EACCES: permission denied, unlink '/usr/local/bin/jhipster' npm ERR!      errno: -thirteen, npm ERR!      lawmaking: 'EACCES', npm ERR!      syscall: 'unlink', npm ERR!      path: '/usr/local/bin/jhipster' }, npm ERR!   stack: npm ERR!    'Error: EACCES: permission denied, unlink \'/usr/local/bin/jhipster\'', npm ERR!   errno: -thirteen, npm ERR!   code: 'EACCES', npm ERR!   syscall: 'unlink', npm ERR!   path: '/usr/local/bin/jhipster' } npm ERR!  npm ERR! The operation was rejected past your operating arrangement. npm ERR! It is probable you do not have the permissions to access this file as the electric current user npm ERR!  npm ERR! If you believe this might be a permissions consequence, please double-check the npm ERR! permissions of the file and its containing directories, or effort running npm ERR! the command again as root/Administrator (though this is not recommended).  npm ERR! A complete log of this run can be constitute in: npm ERR!     /home/operatorfeitam/.npm/_logs/2020-11-22T10_17_16_979Z-debug.log                  

This is because the /usr/local/lib/nodes_modules directory (where global node libraries are installed past default) is root and does non have permissions by the user who ran the command with npm to install or access installed packages.

Earlier fixing it nosotros ostend that it is by the in a higher place looking at the configuration that we have in node with:

          npm config listing                  

Which in my example returns to me:

          [operatorfeitam@dev01 ~]$ npm config list ; cli configs metrics-registry = "https://registry.npmjs.org/" scope = "" user-agent = "npm/half-dozen.9.0 node/v10.16.2 linux x64"  ; node bin location = /usr/local/bin/node ; cwd = /domicile/operatorfeitam ; HOME = /dwelling/operatorfeitam ; "npm config ls -l" to testify all defaults.  [operatorfeitam@dev01 ~]$                  

Nosotros see that the location of the node binary is in the usual default folder /usr/local/bin, and that a node v10.16.two version is used. Now we check where the global libraries are installed with the control:

          npm list -grand | head -1                  

or:

          npm list -k                  

This command returns in my case:

          [operatorfeitam@dev01 bin]$ npm list -g /usr/local/lib ├─┬ create-react-app@ii.1.8 │ ├─┬ chalk@1.ane.3 │ │ ├── ansi-styles@ii.2.one │ │ ├── escape-string-regexp@1.0.5 │ │ ├─┬ has-ansi@ii.0.0 │ │ │ └── ansi-regex@2.ane.ane │ │ ├─┬ strip-ansi@3.0.1 │ │ │ └── ansi-regex@2.one.1 deduped │ │ └── supports-color@ii.0.0 │ ├── commander@2.18.0 │ ├─┬ cross-spawn@4.0.2 ... ...   ├─┬ worker-farm@1.6.0   │ └─┬ errno@0.1.7   │   └── prr@1.0.1   └─┬ write-file-atomic@2.iv.ii     ├── graceful-fs@4.i.15 deduped     ├── imurmurhash@0.1.4 deduped     └── signal-go out@3.0.2 deduped  [operatorfeitam@dev01 bin]$                  

Note: With the command 'npm list -g' you get on the starting time line this location and all the global libraries installed. The 'npm list' command gets the non-global libraries that will be installed in a subfolder named node_modules from the location you are in when you run the npm installation control.

The previous command returns that the global library installation folder named node_modules located in /usr/local/lib. And if nosotros therefore check who owns this path /usr/local/lib/node_modules see the source of the problem: it is owned past the root user.

          [operatorfeitam@dev01 lib]$ pwd /usr/local/lib [operatorfeitam@dev01 lib]$ ls -la full eight drwxr-xr-x.  4 root root   41 Sep 20 19:34 . drwxr-xr-10. fourteen root root 4096 November 15  2018 .. drwxrwxrwx.  seven root root 4096 Nov 22 eleven:17 node_modules drwxr-xr-x.  iii root root   26 Sep 20 19:34 python3.6 [operatorfeitam@dev01 lib]$                  

The "prefix" aspect of the configuration that can exist seen with the command 'npm config ls -l', which displays all the default values that the 'npm config list' command does non render, is the one that specifies where the global libraries are located that is in {prefix}/lib/node_modules. And the binaries in {prefix}/bin and the man pages in {prefix}/share/human.

If we run into the value of "prefix" with the command:

          npm config ls -l | grep prefix                  

gives us back:

          [operatorfeitam@dev01 lib]$ npm config ls -l | grep prefix prefix = "/usr/local" salvage-prefix = "^" tag-version-prefix = "v" [operatorfeitam@dev01 lib]$                  

That matches what we've seen before, and that nosotros've checked for the root user's node_modules prefix/lib/node_modules.

The solution is to create a binder in the user'due south home, to avoid permission issues, which has the problem locating the installation of global node libraries for that user.

For this nosotros create a hidden binder with the name .npm-usr-local (can be any name) in the user'south home with the command:

          mkdir ~/.npm-usr-local                  

Then we specify the "prefix" aspect in the node configuration with the command:

          npm config fix prefix '~/.npm-usr-local'                  

So in the .bash_profile file in the instance of CentOS or .profile or counterpart in other linux distributions we add together to the PATH the bin of this created folder which is where the binaries of the global libraries volition be installed:

We reload the system variables past running the post-obit command to reload the .bash_profile:

          source ~/.bash_profile                  

We verify that the 'npm config listing' command at present gives us the new value of the "prefix" attribute:

And now we can install the generator-jhipster node library:

          [operatorfeitam@dev01 client01-app-projection]$ npm install -g generator-jhipster npm WARN deprecated asking@ii.88.2: request has been deprecated, meet https://github.com/request/request/issues/3142 npm WARN deprecated har-validator@5.1.5: this library is no longer supported /home/operatorfeitam/.npm-usr-local/bin/jhipster -> /home/operatorfeitam/.npm-usr-local/lib/node_modules/generator-jhipster/cli/jhipster.js  > ejs@two.7.four postinstall /home/operatorfeitam/.npm-usr-local/lib/node_modules/generator-jhipster/node_modules/mem-fs-editor/node_modules/ejs > node ./postinstall.js  Thank you for installing EJS: built with the Jake JavaScript build tool (https://jakejs.com/)   > spawn-sync@1.0.15 postinstall /home/operatorfeitam/.npm-usr-local/lib/node_modules/generator-jhipster/node_modules/spawn-sync > node postinstall   > ejs@3.1.iii postinstall /home/operatorfeitam/.npm-usr-local/lib/node_modules/generator-jhipster/node_modules/ejs > node --harmony ./postinstall.js  Thank you for installing EJS: congenital with the Jake JavaScript build tool (https://jakejs.com/)  + generator-jhipster@6.10.five added 705 packages from 479 contributors in 23.214s [operatorfeitam@dev01 client01-app-projection]$                  

All that remains is to run 'npm list -g' again where we will see that the new path specified in "prefix" is used with the generator-jhipster library installed and its dependencies

And if nosotros access the .npm-user-local binder we see that it already has a bin and lib directory that has been created and that contain the libraries and binary installed previously.

kramerthermed.blogspot.com

Source: https://feitam.es/how-fix-the-error-eacces-permission-denied-unlink-usr-local-bin-jhipster-when-installing-generator-jhipster-library-node-with-npm/

0 Response to "Vsts Build Please Try Running This Command Again as Root/administrator."

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel