Work on node.js module in place - node.js

I'm working on my node.js demo.location.io web app at the same time as my location.io library. I'd like to be able to make changes to the location.io library and push them up to github from inside the node_modules folder. Is there any support for this in npm?

(If I understand your question) You can use
npm link
to link your location.io to your local demo.location.io repo. More info here

Related

Heroku with Node not clearing/updating the node_modules folder for a github based library

We have a node web project hosted off of Heroku that contains a library hosted on GitHub. We often make changes to the GitHub library.
When we push the updated node web project to Heroku for deployment, it doesn't check if the library on GitHub has been updated.
We're wondering if there is a command that clears the cache/node_modules folder on Heroku to resolve this?
Cheers,
Peter
I found the solution after searching for a while. You have to disable the cache via config and also purge the existing one for old builds. Also I recommend deleting the package-lock.json to clear any issues.
https://devcenter.heroku.com/articles/nodejs-support#cache-behavior
https://help.heroku.com/18PI5RSY/how-do-i-clear-the-build-cache

How to import and use a modified npm library packages dynamically

I am using a sigmajs library for creating node based graph visualisations. But the library package had a few bugs, so I modified a few files in the source code of the library and fixed them.
I have hosted my graphs on django server, and whenever I host it, the sigma package in the package.json gets loaded dynamically each time. The static library files on my machine which I had modified and fixed bugs don't get loaded. So,I get the same old package and not the modified one.
How do I access the modified library package dynamically when I host the server.
My advice is that of copying your fixed version of the library on server and install it from local path instead of remote npm repository like this:
npm install --save /path/to/fixed/lib/dir/in/server.
See this answer: npm local install
Pay attention that your fixed lib won't be sync with official one.
I don't know how you modify the library but i suggest to fork the official repository and syncronize your local one with remote one as for example explaind here sync forked repo github.
In this way you can sync to official repo while you mantain your fix and you will install your modified local one. Eventually consider to open issues and PR on sigmajs official repo to apply your fix directly to official library. If they will be accepted you can then install directly official version.

Using locally develop npm module

I have developed a nodejs project as an umd library, with the purpose to use it in a another nodejs project. The library project builds fine and generates the index.js file and index.min.js file.
But when I tried installing the library project locally using npm install "asolute path". It brings all the things in the library project. And the size of my project I want to use the library project grew. Seems it is because of all the files in library project is getting copied.
Thanks for any help in advance.
Have you added an .npmignore file?
Also, you'll probably want to use npm link for local development.

Whats the role of Node.js in a Polymer setup?

Why do I have to install Node.js to work with Polymer? Just because of npm? Are there any other uses for Node.js in a typical Polymer project? Or is npm just used to install Bower, and Bower to install project dependencies?
Node.js is just use to create project files. create a polymer project you have to use the console polymer CLI.
once files are generated you don't need the CLI until new project or to modify the current one.
You don't need Node.js. You can download all the components you want (plus all their dependencies and polyfills) from Github yourself, and organize them in your project directory. You also don't need any project files if you're going that route.
If you want, however, to conveniently install the components and all their dependencies, you can use bower, or the more recent yarn, which use Node.js. Also, if you want to host your project on Github or similar, it's useful to just commit bower.json which contains a list of all the dependencies (and can then conveniently be installed after cloning the repo), instead of forking all of Polymer's code into your project repo.
Having this said, if all you need is Polymer itself without any of the web components Polymer provides, it's probably even easier to just download Polymer and the required polyfills yourself.
There are more uses for Node.js. You may want to use some packages in your Polymer project, such as Redux, which you can also just download yourself, or install using NPM/Node.

Which files from Node.js app must be uploaded to a web-hosting?

Perhaps this is a silly question. It came out while I was learning how to set up a Node.js application for production on Ubuntu and digital ocean.
Let's say I have a simple data visualization app made in Node.js, using node modules such as express, page, axios, yo-yo, and browserify to compile my files.
I want to upload my app to a webhost that already exists.
This is the structure's app:
node_modules
public (app.js and app.css)
src (header, home, and footer folders)
views (index.pug file)
gulpfile.js
index.scss
package.json
server.js
Which files I need to upload in order to see my app as I see it in localhost?
You need to upload everything.
What Maximelian says is true if you're going to run npm install again on your server. The standard way of doing this is sync the project using git (you can find a .gitignore template for node.js here).
Once setup you'd do something like this on the server after making the commit locally, and pushing to your remote git repo:
git pull
npm install
npm start
If you were to just ftp the full working project including node_modules it would work just by running npm start. But the above method is what I'd recommend.
If I remember correctly everything except node_modules, if you did not customized them. (rewrite some behavior after module installation)

Resources