Permissions NPM / Cordova Error: EACCES: permission denied, scandir

When I run cordova plugin add cordova-plugin-geolocation, I get the following error. I tried to include 777 in this folder, setting myself as the owner, etc. In these circumstances, I am not allowed to use sudo, but I am sure if I can solve this problem.

Failed to install 'cordova-plugin-geolocation': Error: EACCES: permission denied, scandir '/Users/username/documents/core/myapp/app/platforms/ios/build/device/libCordova.a'
    at Error (native)
    at Object.fs.readdirSync (fs.js:952:18)
    at GlobSync._readdir (/Users/username/documents/core/myapp/app/platforms/ios/cordova/node_modules/glob/sync.js:275:41)
    at GlobSync._readdirInGlobStar (/Users/username/documents/core/myapp/app/platforms/ios/cordova/node_modules/glob/sync.js:254:20)
    at GlobSync._readdir (/Users/username/documents/core/myapp/app/platforms/ios/cordova/node_modules/glob/sync.js:263:17)
    at GlobSync._processReaddir (/Users/username/documents/core/myapp/app/platforms/ios/cordova/node_modules/glob/sync.js:135:22)
    at GlobSync._process (/Users/username/documents/core/myapp/app/platforms/ios/cordova/node_modules/glob/sync.js:130:10)
    at GlobSync._processGlobStar (/Users/username/documents/core/myapp/app/platforms/ios/cordova/node_modules/glob/sync.js:360:10)
    at GlobSync._process (/Users/username/documents/core/myapp/app/platforms/ios/cordova/node_modules/glob/sync.js:128:10)
    at GlobSync._processGlobStar (/Users/username/documents/core/myapp/app/platforms/ios/cordova/node_modules/glob/sync.js:363:10)
Error: EACCES: permission denied, scandir '/Users/username/documents/core/myapp/app/platforms/ios/build/device/libCordova.a'
+4
source share
1 answer

NPM problem

You can fix this problem using one of three options:

  1).Change the permission to npm default directory.
  2).Change npm default directory to another directory.
  3).Install node with a package manager that takes care of this for you.

Before moving, you must back up your computer.

Option 1: change permissions to npm default directory

1). Find the path to the npm directory:

    npm config get prefix

For many systems, this will be / usr / local.

. /usr, 2 .

2). npm- ( !):

  sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}

, npm (lib/ node_modules, bin share).

2: npm

, npm (,/usr), , , .

npm . .

1). :

 mkdir ~/.npm-global

2). npm :

 npm config set prefix '~/.npm-global'

3). ~/.profile :

 export PATH=~/.npm-global/bin:$PATH

4). :

 source ~/.profile

. sudo.

 npm install -g jshint

2-4 ENV (, ~/.profile):

  NPM_CONFIG_PREFIX=~/.npm-global

3. , .

node Mac OS, , Homebrew. "Homebrew" .

  brew install node
+6

Source: https://habr.com/ru/post/1682074/


All Articles