getnamo/NodeJs-Unreal

Issue using modules

Opened this issue · 1 comments

Hey I downloaded the ue5 release and started playing around. I am using 5.1 if that makes a difference.
I can run a script as expected with a console.log, but when I tried to copy the code example over to use the ipc example it throughs the following error:

LogTemp: Error: Script Error: node:internal/modules/cjs/loader:998
  throw err;
  ^
Error: Cannot find module 'ipc-event-emitter'
Require stack:
- C:\Users\bedna\OneDrive\Documents\Unreal Projects\UnorthodoxSimulation\Content\Scripts\index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (C:\Users\bedna\OneDrive\Documents\Unreal Projects\UnorthodoxSimulation\Content\Scripts\index.js:4:13)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\bedna\\OneDrive\\Documents\\Unreal Projects\\UnorthodoxSimulation\\Content\\Scripts\\index.js'
  ]
}
Node.js v18.12.1

I currently have the Nodejs component set to auto resolve decencies and I am also calling it manually in my actor. The Node modules in the plugin are there. I also have the same dependencies listed in the package.json in the Content/Script as I do in the plugins package.json
I haven't changed the name of the files as its simply 'index.js' in the root of the 'Scripts' folder. If I component out the parts relating to the ipc I can get a console.log back.

are there any possible steps I missed?

I do have a global node 20 installed that I am using for other projects.

I believe it's related to: #46

This hints at the change in new node releases that deprecate programmatic API for NPM. The plugin will need to retool to use the commandline api instead. Currently looking for help with this feature as the available time to fix it myself is unknown at this moment.

The workaround for now is to pre install dependencies by going into the script folder where you have your scripts and installing dependencies using commandline (or copying them over).