All node for max patches open as text. What am I doing wrong?


    Oct 04 2018 | 6:36 pm
    Hi folks!
    Like the title says, all the node for max patches I tried open as text. I tried the ones from https://github.com/Cycling74/n4m-examples What am I doing wrong? Other patches open normally.
    For example here is the one for sockets:
    Thank you for your help, ygreq

    • Oct 04 2018 | 6:42 pm
      I think I just realized something. It's related on how I download them from github. I right-clicked and saved as as the file was maxpat. But this seems not to work. So the question now is how do I download them?
      I copy/pasted the code in the patch but I think there's a better way. i just don't know it.
      Thank you!
    • Oct 04 2018 | 7:05 pm
      Jeeez, I knew about this trick, but I was looking for it on each project separately. ;)) So I missed it on the main page. Thanks
    • Oct 04 2018 | 8:22 pm
      I got a sneaky trick for you—if you click on Extras and go down to n4m.launch, there's a button in the patch that opens that says "More Examples". That button takes you to a patcher that will actually download the n4m-examples for you (using node to download node, drive while you drive etc. etc.)
      In hindsight no, I don't really know how you were expected to discover that. But I'm excited that you're checking out the Node examples!
    • Oct 04 2018 | 10:34 pm
      N4M is mostly a collaboration between Florian and me. Thanks, I hope it's useful for you. And remember, if you make something cool, n4m-examples is a public repo, and we're excited for people to add their own examples.
    • Oct 05 2018 | 11:56 am
      Hey Sam! Thank you so much for your help and for this wonderful object.
      Is there a tutorial out there on how to import new packages from npm into node for max? I wanted to try a few ones. I am novice in js and node, btw.
    • Oct 05 2018 | 12:19 pm
      Hey, happy to help! I'm hearing this a lot from people, that they want a better understanding of how to get packages from npm working with Max. For now, this is the best I can offer, sorry it's a self-plug:
      I'll try to work on some material that's a bit more concise, and that focuses on this particular problem domain.
    • Oct 05 2018 | 4:12 pm
      For starters u can just send a message script npm install <package> . For more advanced use-cases we recommend using a package.json file to maintain your project's dependencies, their versions etc. More info can be found here: https://docs.npmjs.com/files/package.json
      But the basic principle is, create a package.json file (minimal info is fine) next to the js script you are referencing
      {
          "name": "my-n4m-project",
          "version": "0.1.0",
          "dependencies": {
          }
      }
      Form there one sending any npm commands to the node.script object will act similar to running anything from the CLI. So for example npm install tonal will install the tonal package and add it as a dependency entry to your package.json.
      Please note that it's not necessary to have a system wide Node installation on your machine (as shown in the video Sam linked to) as Node For Max bundles it's own Node and NPM versions and as long as you operate it from the patch things should "just work" as if you were running them from the CLI.
    • Oct 05 2018 | 10:36 pm
      Hey guys! Thank you for your support. Newbie in js here, like I said, so I am trying to take it one step at a time. My guess is that I took a project that is a bit too big for a beginner, but I wanted to do this months ago. I actually wrote a couple of posts asking for help on how to use Binance API inside max :) I am trying to use this package https://www.npmjs.com/package/node-binance-api .
      So here goes..
      <<For starters u can just send a message script npm install <package> >> I cannot just send a message to node.script as long as it does not have a name (node.script: nodescript argument must be a <path>) So now I am guessing I would have to create a js file for it like Sam did. <<Please note that it's not necessary to have a system wide Node installation on your machine (as shown in the video Sam linked to) as Node For Max bundles it's own Node and NPM versions and as long as you operate it from the patch things should "just work" as if you were running them from the CLI. >> How would you go about creating the tonal package from max? Thank you!!
    • Oct 06 2018 | 8:15 pm
      I finally managed while steadily going through Sam's tut. The newbie steps below:
      a.Click the Start button , click Control Panel, click Programs, and then click Turn Windows features on or off.
      b.Enable Windows Subsystem for Linux
      c.To get Bash installed, open Command Prompt and type “bash”
      d.Afterwards, install a linux distro onto Windows (eg Kali Linux)
      a.Go to folder - cd [drag and drop folder path]
      b.Create package.json - npm init
      c.Install npm package - install npm -s [name of package]
    • Oct 06 2018 | 8:18 pm
      So. Just for the record, you don't _have_ to install nvm. I know I recommended it in that video, but you don't have to. You can also access npm right from the node.script object, without installing anything. Just send it a message like (script npm install -s [name of package]). Sorry for the confusion this video caused...
    • Oct 07 2018 | 11:40 pm
      Thank you, Sam!