I wrote a node-addon-api
module that binds a subset of Syphon-Framework
with node
. It can be integrated in an Electron
app or in a nodejs server.
The package in question: node-syphon
For this to work, I have to configure own Syphon and addon's gyp library search paths, and I end up with copying Syphon in the dist/Frameworks
folder.
If built locally and installed from local file everything goes well and it can be bundled as dependency in another app.
But, when I want to publish the package to npm
, it complains about ENOTDIR: not a directory, open '[MY_PATH]/dist/Frameworks/Syphon.framework/Syphon/package.json'
.
npm is looking in subfolder for this package.json
file, but I don't understand why and if there is a way to avoid that.
More generally, I could understand that publishing this kind of dependency is disallowed. If this the case is there any workaround to allow to npm i
this package?
In a postinstall
script?
Thank you.
EDIT 20250125
The error, that also appears when using npx
in one of my examples and that could to be related to the use of yarn workspaces, is as follow:
Error: ENOTDIR: not a directory, open '[MY_PATH]/node-syphon/packages/lib/dist/Frameworks/Syphon.framework/Syphon/package.json'
at async open (node:internal/fs/promises:639:25)
at async readFile (node:internal/fs/promises:1249:14)
at async mapWorkspaces ([MY_USER_PATH]/.nvm/versions/node/v20.15.0/lib/node_modules/npm/node_modules/@npmcli/map-workspaces/lib/index.js:144:13)
at async Config.loadLocalPrefix ([MY_USER_PATH]/.nvm/versions/node/v20.15.0/lib/node_modules/npm/node_modules/@npmcli/config/lib/index.js:682:28)
at async Config.loadProjectConfig ([MY_USER_PATH]/.nvm/versions/node/v20.15.0/lib/node_modules/npm/node_modules/@npmcli/config/lib/index.js:611:5)
at async Config.load ([MY_USER_PATH]/.nvm/versions/node/v20.15.0/lib/node_modules/npm/node_modules/@npmcli/config/lib/index.js:247:5)
at async #load ([MY_USER_PATH]/.nvm/versions/node/v20.15.0/lib/node_modules/npm/lib/npm.js:159:5)
at async module.exports ([MY_USER_PATH]/.nvm/versions/node/v20.15.0/lib/node_modules/npm/lib/cli/entry.js:42:37)
It is actually a problem with the use of yarn workspaces with the npm CLI and is not related to Cocoa framework dependency.
According to this issue npm CLI looks after a package.json in symbolic links.
If it's not possible to update node
and npm
, a proposed provisional solution is to keep all workspaces in a root (e.g. 'packages') directory and to configure workspaces with (quoted from the issue):
"workspaces": [
"scripts/*", // instead of **, could you try with *
]
If it is possible to update, this PR resolves the problem.
To install (20.17.0 or upper):
nvm install 20.17.0
nvm alias default v20.17.0
npm install -g npm@latest