Search code examples
node.jsazureazure-webjobs

Azure Web App WebJob not installing node packages


I am trying to create a webjob using nodejs, the scripts use various node modules, however when the job runs it doesn't appear to install the packages up front.

The zip file i upload has a package.json with all the dependencies and a server.js in the root of the zip, the script get executed but as per the log below it can't find the modules to run.

I am getting the following output in the log.

[07/28/2015 07:36:14 > 5fabb6: SYS INFO] Status changed to Initializing
[07/28/2015 07:36:14 > 5fabb6: SYS INFO] Run script 'server.js' with script host - 'NodeScriptHost'
[07/28/2015 07:36:14 > 5fabb6: SYS INFO] Status changed to Running
[07/28/2015 07:36:15 > 5fabb6: ERR ] 
[07/28/2015 07:36:15 > 5fabb6: ERR ] module.js:340
[07/28/2015 07:36:15 > 5fabb6: ERR ]     throw err;
[07/28/2015 07:36:15 > 5fabb6: ERR ]           ^
[07/28/2015 07:36:15 > 5fabb6: ERR ] Error: Cannot find module 'sendgrid'
[07/28/2015 07:36:15 > 5fabb6: ERR ]     at Function.Module._resolveFilename (module.js:338:15)
[07/28/2015 07:36:15 > 5fabb6: ERR ]     at Function.Module._load (module.js:280:25)
[07/28/2015 07:36:15 > 5fabb6: ERR ]     at Module.require (module.js:364:17)
[07/28/2015 07:36:15 > 5fabb6: ERR ]     at require (module.js:380:17)
[07/28/2015 07:36:15 > 5fabb6: ERR ]     at Object.<anonymous> (D:\home\site\wwwroot\App_Data\jobs\triggered\TestWebJob\dist\services\email.service.js:4:16)
[07/28/2015 07:36:15 > 5fabb6: ERR ]     at Module._compile (module.js:456:26)
[07/28/2015 07:36:15 > 5fabb6: ERR ]     at Object.Module._extensions..js (module.js:474:10)
[07/28/2015 07:36:15 > 5fabb6: ERR ]     at Module.load (module.js:356:32)
[07/28/2015 07:36:15 > 5fabb6: ERR ]     at Function.Module._load (module.js:312:12)
[07/28/2015 07:36:15 > 5fabb6: ERR ]     at Module.require (module.js:364:17)
[07/28/2015 07:36:15 > 5fabb6: SYS INFO] Status changed to Failed
[07/28/2015 07:36:15 > 5fabb6: SYS ERR ] Job failed due to exit code 8

Solution

  • The best way to do this appears to be manually ftping the node_modules up into the correct folder. As per https://github.com/projectkudu/kudu/wiki/Web-jobs#copying-files-directly-in-their-proper-location

    What i did was to create the webjob without the node_modules folder and then ftp up the files separately.

    Upload your node module to the following folder via ftp

    • /site/wwwroot/node_modules

    ftp view of azure node website