question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow node modules to have node modules as dependencies

See original GitHub issue

Node-red scans for node_modules directories starting from its install location and working up the tree to the root path. When it finds such a directory, it examines the package.json files of the modules in the directories immediately below; it doesn’t scan deeper for additional node_module directories.

This means a node module cannot declare another node module as a dependency and have it load properly - which is a reasonable thing to allow.

  • when a valid node-red node module is discovered, scan its node_modules directory
  • ensure we are recording the version number of node modules
  • if a node module is found that we have already loaded:
    • if the version number matches, skip it and carry on.
    • if the version numbers don’t match, refuse to load it (and if this was in a node module’s node_module directory, refuse to load the top level module as its dependency cannot be satisfied)

Issue Analytics

  • State:open
  • Created 9 years ago
  • Comments:26 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
tvecommented, Apr 13, 2022

Just to provide a bit of perspective. Due to this bug, to install FlexDash using the palette manager I would have to tell users to manually install node-red-fd-corewidgets and node-red-flexdash and node-red-flexdash-plugin. Most likely, there’s also going to be a node-red-flexdash-sidebar to add to the list. If a user installs the corewidgets but forgets to install one of the other packages then at a first glance everything seems to work, except that config nodes are missing and therefore the input fields in the flow editor don’t work. The net result are nodes that seemingly are there but somehow don’t work.

Instead, I will have to recommend to install using npm, where just installing node-red-fd-corewidgets before launching node-red brings in everything else and works properly.

This is particularly a shame when using docker, because instead of just something like

docker run --rm -ti -p 1880:1880 nodered/node-red:2.2.2

and then using the flow-manager to get FlexDash one has to run:

docker run --rm -ti -p 1880:1880 --entrypoint bash nodered/node-red:2.2.2 \
  -c "npm i @flexdash/node-red-fd-corewidgets; npm start --cache /data/.npm -- -v -userDir /data"
1reaction
dceejaycommented, Mar 15, 2018

you can also use npm pack to package your code locally into an installable tgz file without having to publish it. You can then install it with npm i your_package_name.tgz

Read more comments on GitHub >

github_iconTop Results From Across the Web

Understanding dependency management with Node Modules
Packages can be installed in projects on your local machine using a command line package manager such as npm or yarn and are...
Read more >
How To Use Node.js Modules with npm and package.json
Packages that are used for the development of a project but not for building or running it in production are called development dependencies....
Read more >
How to specify local modules as npm package dependencies
json dependencies structure. Using the --save option in this command is simply putting "mymodule": "0.0.0" into my package.json ( ...
Read more >
Requiring modules in Node.js: Everything you need to know
Node modules have a one-to-one relation with files on the file-system. We require a module by loading the content of a file into...
Read more >
Creating Node.js modules - npm Docs
To create a package.json file, on the command line, in the root directory of your Node.js module, run npm init : · Provide...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found