Giter Club home page Giter Club logo

Comments (2)

johnelm avatar johnelm commented on June 11, 2024

hi @id347627

what ide I should use to run and play around with example.js?

You can use any IDE you like to try the example. My fave is vscode (Visual Studio Code). As I mentioned in the README.

So long as your editor can launch a shebang'd script, you can run or debug JXA while you edit.

I do this in vscode using the Code Runner extension. Its code-runner.respectShebang config setting in vscode must be set to true (the default setting).

But, you don't have to use an IDE at all to run the script, and this is largely the 'raison d'être' for node-jxa.. to be able to run your JXA scripts, potentially using modules from NPM, from your terminal or from any script launcher that can start a shell script, e.g. FastScripts, Alfred, Automator, etc.

what do I need to set up?

  • install node-jxa globally, using yarn or npm, as described in the README file's Installation and usage section.
  • chmod the script so it has execute permissions: chmod +x ./example.js, also described in the README file's Installation and usage section. (see comment at bottom)

Dependencies

You must also make sure the script's dependencies are installed and available to node-jxa, as mentioned in the Project structure and availability of node modules section of the README.

the example.js file

For the example.js file in a local clone of node-jxa, this is easiest by running yarn or npm install from your local clone's project dir.

  • please regard the comments in example.js for other requirements, i.e. permissions for showing OSX notifications
real-world usage

For real-world usage, you can install the dependencies:

  • globally via npm install -g or yarn global add, or
  • in any folder where node-jxa (actually Browserify) can find them, by running npm install <module> or yarn add <module>:
    • in the same dir as the script, creating node_modules as a sibling dir to your script, or
    • in any parent dir, creating node_modules as a '[great] uncle' dir to where your script is.

The logic for how node finds dependencies is detailed in the node.js docs here, in the few sections starting with 'Loading from node_modules Folders'.

from node-jxa.

johnelm avatar johnelm commented on June 11, 2024

I just realized that the example.js script (in the git repo) doesn't have execute permissions; I've created an issue to update its permissions so it's not necessary to chmod it before trying it.

I'll make a note to add a bit more info on dependencies to the README too.

from node-jxa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.