1

I'm trying to take my first steps in node.js and I've been following this tutorial: https://learn.microsoft.com/en-us/azure/app-service-api/app-service-api-nodejs-api-app When I'm typing npm install -g yo to the cloud shell in azure I get this error:

npm ERR! Linux 4.4.0-83-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "yo"
npm ERR! node v6.9.4
npm ERR! npm  v3.10.10
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access

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

npm ERR! Please include the following file with any support request:
npm ERR!     /home/shiran_dror/app-service-api-node-contact-list/npm-debug.log

How do I use the shell as root/Administrator?

jluk
  • 1,000
  • 7
  • 12
Shiran Dror
  • 1,472
  • 1
  • 23
  • 36

3 Answers3

2

You're supposed to install Swaggerize on your local machine, not in the Cloud Shell.

Install Swaggerize on your local machine. Swaggerize is a tool that generates Node.js code for your REST API from a Swagger definition.

When done developing locally, push to App Service with git (section "Deploy the API with Git" from the docs).

evilSnobu
  • 24,582
  • 8
  • 41
  • 71
1

In Cloud Shell today you are set as a regular user without sudo permissions. As a result you cannot run sudo cmds from Cloud Shell currently. In the tutorial you are following, Cloud Shell helps for the sections that require az commands to create the Azure app service since the Azure CLI 2.0 is maintained and updated for you there.

The section where you are npm installing Swaggerize is meant to be on your local machine, the instructions include this detail.

jluk
  • 1,000
  • 7
  • 12
0

It seems your user doesn't have the permission to install in /usr/local/lib/node_modules. Try removing the -g option to install locally.

Use sudo in front of npm install command to switch to root user for this command (if you're allowed to do that).

JSchirrmacher
  • 3,243
  • 2
  • 19
  • 27