Azure Web App WebJob does not install node packages

I am trying to create a webjob using nodejs, the scripts use various node modules, however when starting the task it does not show the installation of packages in front.

The mail file I upload has package.json with all the dependencies and server.js in the zip root, and the script is executed, but according to the log below it cannot find the modules to run.

I get 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 
+4
source share
3 answers

The best way to do this is apparently to manually move node_modules to the correct folder. By https://github.com/projectkudu/kudu/wiki/Web-jobs#copying-files-directly-in-their-proper-location

What I did was create a website without the node_modules folder, and then the FTP files separately.

Download the node module to the following folder via ftp

  • / site / wwwroot / node_modules

ftp view azure node website

+4
source

WebJobs will not start npm until the script is executed, so be sure to include the modules that the application depends on in the application, for example. include node_modules in the zip file that you download through the portal.

+1
source

You do not need to load node modules. This defeats the goal of simply pushing git. And you do not want to include node modules in the git repository.

The β€œsecret” is to add the dependencies of the node module to your main package.json project, and then add your web jobs to your base project folder with this structure:

App_Data \ jobs \ continuous \ [job name]

The web job in this folder should not have package.json or node modules, because it uses the modules specified in the main package.json project. Its main file should be called "run.js".

I just discovered this today, and you’re ashamed that you need to dig through the entire Internet before you know that you don’t need to manually upload web tasks to the Azure portal. Microsoft, please add documentation for these things for people using node.js. Azure is an awesome platform! But the barrier to entry for Azure with node.js is high because of such things.

See this useful article for more details:

http://blog.amitapple.com/post/74215124623/deploy-azure-webjobs/#.V6JkF7grKUl

0
source

All Articles