Closed id347627 closed 5 years ago
hi @id347627
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.
yarn
or npm
, as described in the README file's Installation and usage section.chmod +x ./example.js
, also described in the README file's Installation and usage section. (see comment at bottom)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.
example.js
fileFor 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.
example.js
for other requirements, i.e. permissions for showing OSX notificationsFor real-world usage, you can install the dependencies:
npm install -g
or yarn global add
, ornpm install <module>
or yarn add <module>
:
node_modules
as a sibling dir to your script, ornode_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'.
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.
what ide I should use to run and play around with example.js? what do I need to set up?