Include installed npm-packages into your M4L device when distributing? Possible?
Hello!
Let's say I created M4L device, which uses Node for Max with additional npm-packages installed. How can I include installed npm-packages (node-modules folder) into my M4L device when distributing? What is the strategy here? Or should I ask users to click on a message 'script npm install ...' to node.script object on the first device run?
Hey, so I've got a bit of bad news for you, which is that there are some difficulties getting M4L devices and Node for Max to work together, difficulties that we haven't had the chance to resolve yet.
The good news is that we're aware of these difficulties, and are working on a comprehensive fix for the problem (comprehensive in the sense of having a reasonable way of handling folder dependencies which aren't necessarily dependencies of the patcher per se, such as node resources).
Unfortunately, this represents a low-level change to the collective-building process, so there's a bit of work yet to make it happen. You can expect a solution in an upcoming release. In the mean time, thanks for you patience.
Sam, thank you for a prompt answer. Waiting for the fix.
Any news on this topic?
Well, I don't know how satisfying this will be for you, but I can say that we've found a solution that we like, and that it should be coming to the release version of Max in the not-too-distant future. "When is the not-too-distant future, exactly?" I can't say, but it's not too distant.
Ok, thanks for the info!
Hey Valery,
just following up here. This is released with today's 8.0.3 update. So "not-too-distant" already happened ;)
Future is now? ;)
I downloaded and installed the 8.0.3 update.
Thank you for the information, Florian, but it seems something is still broken.
I created a M4L device, which uses 'ableton' package, installed by sending 'script npm install ableton' message to node.script object. The node_modules folder is now more than 3 megabytes. But when I try to freeze the M4L device only four files are added to the package and M4L device refuses to work until I unfreeze it.

So, I'm repeating my initial question: how can I include installed npm-packages (node-modules folder) into my M4L device when distributing?
Thank you for help!
Hey so! It's possible, there's just one new step that you have to go through. First, I'd take everything node related (in your case package.json, PlugView.js and node_modules) and put it into a subfolder called node_stuff or whatever you like. Then, click the little gear at the bottom of the project window, and then click "Search Paths". Then, add a path to the node_stuff folder, but make sure to select "Embedded". This embedded thing is the magic that makes it all work.
Give that a try and let me know how it goes? Thanks for sticking by through this whole process.
Sam, thank you a lot for explaining this. Everything works as expected, now I'm able to successfully freeze the device.
It also works without creating additional subfolder (if you don't want to change the folder structure): you can add individual files using 'Add file to project' command and then add node_modules folder using 'Project Settings - Search paths'...
Issue solved, thank you once again!
That's extremely cool! I'm super excited it worked—we've literally never been able to do this before. Good to know about not changing the folder structure using individual files. I'll keep that in mind for next time. The main thing I wanted to avoid was adding the AMXD itself to its own dependency tree, as I'm not sure what that would have done.
I tested the freezed amxd file on several machines. Looks like everything is OK. There is just one thing I wanted to note: amxd file which use Node for Max created with Max 8.0.3 will not work on machines with earlier Max versions. At least this is what I see. After updating to Max 8.0.3 everything is working as expected.
Thank guys!
Implementing tonal chord library in a m4l device just worked with the "embedded" search path action : )