none
node_module layout RRS feed

  • Question

  • Hello,

    I see that the folder structure specified for Azure functions is as follows from the documentation.

    parentFolder (for example, wwwroot)
     | - host.json
     | - mynodefunction
     | | - function.json
     | | - index.js
     | | - node_modules
     | | | - ... packages ...
     | | - package.json
     | - mycsharpfunction
     | | - function.json
     | | - run.csx

    and I see that the node_modules directory that contains the node packages are stored in the mynodefunction directory. 

    Stating that each function must have its npm dependencies as a sub directory of the function directory. ( Or that is how I interpet the the folder layout from the documentation.)

    So my question is what if I have 4 node functions, does each function need to have it own npm dependencies? or can we have a different layout so  I can share the dependencies between all my functions.

    parentFolder (for example, wwwroot)
     | - host.json
     | - package.json
     | - node_modules
     | | - ... packages ...
     | - mynodefunction1
     | | - function.json
     | | - index.js
     | - mynodefunction2
     | | - function.json
     | | - index.js
     | - mynodefunction3
     | | - function.json
     | | - index.js
     | - mynodefunction4
     | | - function.json
     | | - index.js

    Thanks You

    George


    George

    Friday, April 22, 2016 1:43 AM

Answers

  • Yes you should also be able to put your shared modules in the parent folder. We're not doing anything funky with regards to package resolution, so you can expect normal Node module behavior. Give it a try and let us know if you have any problems :)

    Mathew Charles [MSFT]


    Sunday, April 24, 2016 3:31 PM