Tuesday, 6 June 2017

Node application, manage module dependencies

I'm new in node development and I'm doing a little bit of training in my spare time. Actually I'm able to run the web server and see a static HTML content. For simplicity I created this GitHub public repository. About the folder structure I'd like to use something like this:

node-test
|   .gitignore
|   
+---build
|
\---src

I used Gulp to compile TypeScript and copy needed files from src folder to build maintaining the folder structure. I'm also training in React and you can see a little "Hello World" example in client folder.

Now I'm facing some problem related Node dependencies. Initially I used gulp-npm-files to copy required dependencies into build\node_modules using all the examples found on repository page but always some dependencies are missing. So for the moment the gulp task nodeModules is as you see it: copy the entire src\node_modules in build\node_modules. Certainly is not the tight way but allows Express to run.

I've also another problem about dependencies:

this.app.use(express.static(RouterContants.PublicDirectory));

This line sets the only folder that the browser can access, right? OK, then I cannot access node_modules in same level.

How dependencies have to been managed correctly Have I to combile all js and css files in single ones?

Any suggestions and advices are welcome. The GitHub is public, so I think that you can directly modify it.

Thank you



via Yiyi Chen

No comments:

Post a Comment