johnelm / node-jxa

Use your favorite node.js modules (and JS editor) for your Javascript OSX automation scripts
77 stars 4 forks source link

The 2.1.2 release on NPM includes a reference to a developer-local directory (and doesn't correspond to the Github tag) #35

Open decadent opened 5 years ago

decadent commented 5 years ago

Hi. If you install the current (2.1.2) release from NPM, you'll get an error when Node-jxa runs osacompile:

osacompile: couldn't write to file /Users/john/code/node-jxa/deleteme.scpt: No such file or directory

The vars at the top of node-jxa.js look like this in that release:

const HEAD = 'window = this;\nObjC.import("stdlib");\ntry {\n ';
const TAIL = ';\n} catch (e) {\n console.log( e.message );\n $.exit(1); \n}\n$.exit(0);';
const OSA_JXA_CMD = 'osacompile';
const OSA_JXA_CMD_ARGS = ['-l', 'JavaScript', '-o', '/Users/john/code/node-jxa/deleteme.scpt' ];

You can check code in NPM's module package by getting the archive address with npm view node-jxa dist.tarball and downloading the archive.

My guess is you might want to republish the release if NPM allows that, because code for the release seems to be different here on Github.

heathf commented 5 years ago

I experienced the same. Installing with npm leads to the 'deleteme.scpt' error you mentioned, and like you, it points to the developer's local user path. Copying the contents of GitHub's node-jxa.js over the top of the installation's script of the same name fixed it, but that shouldn't be necessary obviously.

jopemachine commented 4 years ago

You can use npm as it is by changing the package.json's dependencies as shown below.

(Because github's source code is imported as is.)

  "dependencies": {
    ...
    "node-jxa": "github:johnelm/node-jxa#v2.1.2"
    ...
  },