I have a constantly running tcp raw socket that I can connect to using an existing app. I am trying to use socket.io-client in my photoshop plugin, but after installing, my require() statements fail no matter what kind of relative path or whatever I use. npm sees no issues, and I have tried reinstalling as well. I have to use socket.io because all the provided network IO modules with Photoshop UXP are unable to connect to raw TCP.
Process
- I start a terminal in the same folder as my index.js and existing package.json.
- I run npm install socket.io-client
- it succeeds. I now have a node_modules folder and a package-lock.json
- I am unable to use socket.io-client anywhere in my project.
In index.js, these fail, when I am pretty sure they shouldn’t:
const io = require('socket.io-client')
const io = require('./node_modules/socket.io-client')
const {io} = require('socket.io-client')
and so on, even using an absolute path.
When I try this in index.js, the failure is always:
"Module not found: <any/path/to/socket.io-client>. Parent folder was "./"
Other things I have tried:
- uninstalling/deleting node_modules folder and package-lock and trying again.
- Installing using the -global argument.
- using
npm ls
to see that socket.io-client is actually installed.
I have looked everywhere online for help, but I can’t find anyone with a similar problem, please help!
2
Answers
I figured this out. Photoshop plugins (UXP) use a custom JavaScript engine that doesn't check node_modules during require(). There is a forum post I can provide a link to as a source when I am not on mobile. It might work if I use Webpack or other bundling module.
Try to use destructuring assignment:
Reference: Socket IO Documentation