I am writing a custom node for audio communication (quiet-js) and I found a quietjs-bundle (npm package), so I cloned the repo, edited dependencies version, and some minor fixes and I published it to npm too (don`t want to wait until original developer updates it), and started working on the node.
So I installed my package successfully and the post-install is also finished successfully.
(used .nodered directory just for example)
I required the package inside send.js (custom node) const quiet = require('quietjs-bundle-2')
And used npm link to link it as node-red module.
Now when starting node-red in console i get an error:
[error] [send:6eb5368b.3a2f88] Error: Bundle not found. Did you generate it?
The index.js file is just a try/catch for the module.export _bundle.js
I can easily rewrite the code but i want to keep it original as much as I could.
Not sure where to start to find a solution for this, could anyone help?
Does your custom node package.json have a dependency entry for quietjs-bundle-2?
My suggestion would be to have you custom node src in a separate area/directory then in your .node-red folder, issue an npm install /dev/node-red-contrib-mynode to install (link) your dev work in node-red. That way, any (most*) changes while you develop will get picked up on a restart of node-red.
(* Changes to packages would likely need another npm install /srcfolder)
Yes i have quietjs-bundle-2 in my nodes package.json.
The node folder i am using is located in home directory , and i have used sudo npm link and then in .node-red folder npm link node-red-contrib-quiet
I have tried to install in .node-red via the npm as you suggested , still same
The quiet-bundle is also located in home folder.
It should work as it is controled via the console, check index.html
i haven`t tried to run the test yet.
what do you mean with it is controlled via the console?
Modules in Node-RED run in a node.js runtime, not in the browser.
Or I just might not get what you mean.
Okay, so I figured out what was happening, the quietjs-bundle-2 was not publishing the _bundle.js
I resolved the issue, Not sure if the developer even tested this script because now I get an error when trying to start it via Node.js:
Error: ENOENT: no such file or directory, open 'https:/quiet.github.io/quiet-js/javascripts/quiet-emscripten.js.mem'
You no longer need to do all that. As Steve indicates, you can "install" direct from a local folder. That will directly link the development folder to your Node-RED instance. This is how I do all my node development & it is really effective.
As steve also indicated, you can get odd things happening if you have run npm install on your development folder but not from the userDir folder. You can also get issues the other way around too! npm is one very strange beast. Don't get me started on how pre-install scripts don't do what is expected. Nor on the arcane way that npm searches for things.
Without wishing to sidetrack the conversation, you should see the hoops I've had to jump through for uibuilder. Not least of which was wasting 1/2d over the weekend trying to get pre-install scripts to work. In the end I had to give up because something very strange happens and there appears to be no reliable way to pre-install peer dependencies without making a mess of the main install. When peer dependencies were automatically installed, this was never a problem.
The line of code I just posted makes use of window.AudioContext, which is not something that is available in nodejs.
There is no window object and also not the audio API.
no Problem. I also have to state that I am not 100% sure if the code makes use of a different api that is available in nodejs, but as far as I can see from quickly scanning through the code, that audio context is always called if you want to do something with it, so it needs this API.
Maybe you explain what you want to achieve and our Node-RED community is for sure willing to help