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 DeployController.run (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.

Cheers,
Ian

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.

Just go to the root path of your source code and npm i and then forge deploy it should work.

Hi Ira - I am also getting the error,

Error: Bundling failed: Module not found: Error: Can’t resolve ā€˜@forge/ui’ in

and I noticed that in my node_modules folder, I have this:

@forge/
@forge/ui/
@forge/ui/out/

but there is nothing in ā€œoutā€. However, other modules have out populated.

Is that normal?

I have tried npm install @forge/ui in every conceivable way…

Cliff

I was able to solve it by reinstalling @forge/ui package

npm install @forge/ui@latest

Hi Team,

I’m facing the same problem while deploying UI Kit app.

I’ve provided the required permissions, @forge/api is also present in my package.json file, forge/api file is also present in my node_modules. I’ve already run the ā€œnpm install @forge/apiā€, ā€œnmp install -e developmentā€ and "npm install"all these commands but still I’m getting the following error.

Please help with this.

Error: Bundling failed: Module not found: Error: Can’t resolve ā€˜forge/api’ in ā€˜C:\ASPL\Forge Development\First-App\src’

Error: Bundling failed: Module not found: Error: Can’t resolve ā€˜forge/api’ in ā€˜C:\ASPL\Forge Development\First-App\src’
at RuntimeBundler.bundle (C:\Users\chaud\AppData\Roaming\npm\node_modules@forge\cli\out\deploy\packager\runtime-bundler.js:27:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async AppPackager.package (C:\Users\chaud\AppData\Roaming\npm\node_modules@forge\cli\out\deploy\packager\packager.js:16:31)
at async PackageUploadDeployCommand.execute (C:\Users\chaud\AppData\Roaming\npm\node_modules@forge\cli\out\deploy\package-upload-deploy.js:14:76)
at async CommandLineUI.displayProgress (C:\Users\chaud\AppData\Roaming\npm\node_modules@forge\cli\node_modules@forge\cli-shared\out\ui\command-line-ui.js:46:28)
at async DeployView.reportDeploymentProgress (C:\Users\chaud\AppData\Roaming\npm\node_modules@forge\cli\out\command-line\view\deploy-view.js:79:24) at async DeployController.run (C:\Users\chaud\AppData\Roaming\npm\node_modules@forge\cli\out\command-line\controller\deploy-controller.js:172:27)
at async Command.actionProcessor (C:\Users\chaud\AppData\Roaming\npm\node_modules@forge\cli\out\command-line\command.js:91:32)
at async Promise.all (index 0)
at async Command.parse (C:\Users\chaud\AppData\Roaming\npm\node_modules@forge\cli\out\command-line\command.js:194:13)

It looks like you’ve copied project code file from another project folder and module is yet to be installed on a new folder. Following command should work in either case,

npm install @forge/ui@latest

…then go for forge deploy