2

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.
Zuriel Barron
  • 93
  • 1
  • 5
  • Same issue. My only solution so far has been to send my App Service a Docker container with the right files. – Sawtaytoes Oct 13 '18 at 07:09

3 Answers3

0

I had the same issue trying to install serve. In the end, I had to add serve as a dependency in my package.json and execute it locally with the startup command set to node_modules/.bin/serve -s build. Here is my deployment stage;

- task: AzureRmWebAppDeployment@4
  displayName: 'Azure App Service Deploy'
  inputs:
    azureSubscription: $(azureSubscription)
    appType: webAppLinux
    WebAppName: $(webAppName)
    packageForLinux: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
    RuntimeStack: 'NODE|10.10'
    StartupCommand: 'node_modules/.bin/serve -s build'
    ScriptType: 'Inline Script'
    InlineScript: |
    npm install

It is pretty much exactly as Azure DevOps generated it otherwise.

Steztric
  • 101
  • 2
0

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

Timothy Frew
  • 582
  • 3
  • 7
0

You can follow the instructions here to use kudu-yarn: https://github.com/stefangordon/kudu-yarn

It requires you copy a couple files in your project which will get zipped and sent to Azure. When in the App Service, it will utilize the Kudu .deployment file and run deploy.cmd that they've provided.

Sawtaytoes
  • 117
  • 6