Error: Can't resolve '@forge/ui'

I was trying to make my first forge app, I followed all the instructions, I created the app, but when I used forge deploy I got this error:

Error: Bundling failed: Module not found: Error: Can't resolve '@forge/ui' in 'C:\Users\Ezequiel\IdeaProjects\lesson1_forge\src'

Error: Bundling failed: Module not found: Error: Can't resolve '@forge/ui' in 'C:\Users\Ezequiel\IdeaProjects\lesson1_forge\src'
    at AppPackager.package (C:\Users\Ezequiel\AppData\Roaming\npm\node_modules\@forge\cli\out\deploy\packager\packager.js:39:23)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async PackageUploadDeployCommand.execute (C:\Users\Ezequiel\AppData\Roaming\npm\node_modules\@forge\cli\out\deploy\package-upload-deploy.js:11:45)
    at async CommandLineUI.displayProgress (C:\Users\Ezequiel\AppData\Roaming\npm\node_modules\@forge\cli\node_modules\@forge\cli-shared\out\ui\command-line-ui.js:44:28)
    at async DeployView.reportDeploymentProgress (C:\Users\Ezequiel\AppData\Roaming\npm\node_modules\@forge\cli\out\command-line\view\deploy-view.js:50:24)
    at async (C:\Users\Ezequiel\AppData\Roaming\npm\node_modules\@forge\cli\out\command-line\controller\deploy-controller.js:122:27)
    at async Command.actionProcessor (C:\Users\Ezequiel\AppData\Roaming\npm\node_modules\@forge\cli\out\command-line\command.js:76:32)

What can I do? I tried all things that could be on my mind and I can’t get past this part.

Welcome to Atlassian Developer Community, @EzequielGiampaoli !

This normally happens if node_modules directory is not present in your project directory. If this is indeed the case, do an npm install first then call forge deploy again.


Thanks for the solution,
Unfortunately it didn’t work, I already have node_modules, I already did npm install, and the error is still there. I even changed from windows to linux, and in linux I get a similar error, I got this one:
error manifest.yml failed to parse content - end of the stream or a document separator is expected valid-yaml-required

Error: Command failed due to validation error.

Error: Command failed due to validation error.
at PreCommandController.runChecks (/home/ezequiel/.nvm/versions/node/v16.14.2/lib/node_modules/@forge/cli/out/command-line/controller/pre-command-controller.js:24:19)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async /home/ezequiel/.nvm/versions/node/v16.14.2/lib/node_modules/@forge/cli/out/command-line/controller/pre-command-controller.js:32:13
at async Command.checkPreconditions (/home/ezequiel/.nvm/versions/node/v16.14.2/lib/node_modules/@forge/cli/out/command-line/command.js:249:27)
at async Command.actionProcessor (/home/ezequiel/.nvm/versions/node/v16.14.2/lib/node_modules/@forge/cli/out/command-line/command.js:70:53)

So right now I am with an error on both operating systems and don’t know how to fix it.

That’s interesting. Have you tried installing @forge/ui by doing npm i @forge/ui if that fixes the module not found error?

The error you get on linux looks different from the one you got on Windows - the linux error smells like your manifest is malformed somehow while the Windows error is pointing to a missing module that you need to install.

Can you share the link to the instructions you followed so that we can verify if there are missing steps? I followed this tutorial just now and I was able to do a forge deploy successfully. For reference, I am using Forge CLI version 4.1.0.