Azure Linux WebApp – deploy.sh can’t install yarn globally

azureazure-web-apps

I am trying to deploy a React app to an Azure linux webapp using kudu deployment.
I have a pretty standard deploy.sh script with one exception. I want to install the yarn package manager via npm.
When attempting npm install yarn -g the deployment fails. Looking at the logs it looks like a permissions issue.

npm WARN checkPermissions Missing write access to /opt/nodejs/6.11.0/lib/node_modules

Is there a way to install global npm modules on azure linux webapps?

You can see the log here:

Command: bash deploy.sh
Installing Yarn
npm WARN checkPermissions Missing write access to /opt/nodejs/6.11.0/lib/node_modules
/opt/nodejs/6.11.0/lib
npm ERR! Linux 4.13.0-1011-azure
`-- yarn@1.6.0 
npm ERR! argv "/opt/nodejs/6.11.0/bin/node" "/usr/bin/node_modules/npm/bin/npm-cli.js" "install" "yarn" "-g"

npm ERR! node v6.11.0
An error has occurred during web site deployment.
npm ERR! npm  v3.10.10
installing yarn dependency failed
npm ERR! path /opt/nodejs/6.11.0/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access

npm ERR! Error: EACCES: permission denied, access '/opt/nodejs/6.11.0/lib/node_modules'
npm ERR!     at Error (native)
npm ERR!  { Error: EACCES: permission denied, access '/opt/nodejs/6.11.0/lib/node_modules'
npm ERR!     at Error (native)
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/opt/nodejs/6.11.0/lib/node_modules' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

Best Answer

You should run your script with sudo if possible. This will overcome the permissions issue

Related Topic