Comments (2)
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
ornpm
, 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
oryarn global add
, or - in any folder where node-jxa (actually Browserify) can find them, by running
npm install <module>
oryarn 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.
- in the same dir as the script, creating
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.
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)
- remove node-debug-jxa, since the —debug switch can be used in all the same ways
- show error on spurious args
- Add a headsup to README about filesystem limitations HOT 1
- add a tip to simply include `debugger` to debug script
- add this tut to resources (includes tip on JXA with Alfred)
- propose link to node-jxa at these cookbook spots
- research browserify alternatives to work around limitations (i.e. fs access)
- How Do I use Visual Studio Code (VSC) with JXA and Retain JavaScript Code Completion? HOT 4
- Issue with the JXA Application.currentApplication() Object HOT 6
- wrap entire script in a try/catch, and $.exit(1) on error
- add a test confirming that the added code is valid & doesn't cause errors
- move all limitations in the README to a dedicated section
- Feature Request - Add commandline option to generate compiled .scpt file from source HOT 2
- chmod +x the example script in git
- Add info on installing dependencies to README
- The 2.1.2 release on NPM includes a reference to a developer-local directory (and doesn't correspond to the Github tag) HOT 2
- dependency graph error
- First
- Can I import Node-Jxa and use JXA stuff in Node?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-jxa.