mitre / magma

MITRE Caldera's user interface plugin powered by VueJS
Apache License 2.0
3 stars 7 forks source link

Issue when building front-end; Cannot find module 'fs-extra' #17

Closed bjeffries closed 10 months ago

bjeffries commented 10 months ago

When attempting to build front-end, run into issue with a npm module not being found. This is using a clean install of npm with no configuration changes.

codeblaine@Blaines-MBP caldera % npm -v 10.2.0 codeblaine@Blaines-MBP caldera % node -v v21.1.0 codeblaine@Blaines-MBP caldera % python server.py --build 2023-11-13 10:43:14 - INFO (server.py:144 ) Using main config from conf/local.yml 2023-11-13 10:43:15 - INFO (server.py:176 ) Building VueJS front-end.

magma@0.0.0 build node prebundle.js && vite build

node:internal/modules/cjs/loader:1147 throw err; ^

Error: Cannot find module 'fs-extra' Require stack:

Node.js v21.1.0 Traceback (most recent call last): File "/Users/codeblaine/code/ui_test/caldera/server.py", line 177, in subprocess.run(['npm', 'run', 'build'], cwd='plugins/magma', check=True) File "/Users/codeblaine/.pyenv/versions/3.10-dev/lib/python3.10/subprocess.py", line 526, in run raise CalledProcessError(retcode, process.args, subprocess.CalledProcessError: Command '['npm', 'run', 'build']' returned non-zero exit status 1.

bjeffries commented 10 months ago

If you first navigate to the magma plugin and run "npm install", it appears to fix the issue.

Suggested fix would be to update the readme requiring users to run "npm install" within the magma plugin directory first.

JamieScottC commented 10 months ago

Good catch. I'll attempt to fix it by adding a subprocess that runs "npm install" inside the magma directory when the --build flag is present. If that doesn't work then updating the readme should suffice

https://github.com/mitre/caldera/commit/e183398084f18d900ef7535dd8eb7e789ef52c71

JamieScottC commented 10 months ago

Tested and works on fresh install now