Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error while Packaging simple App - The "path" argument must be of type string. Received undefined #126

Closed
JNBG opened this issue Nov 22, 2021 · 4 comments · Fixed by RocketChat/Rocket.Chat.Apps-compiler#44 or RocketChat/Rocket.Chat.Apps-compiler#47

Comments

@JNBG
Copy link

JNBG commented Nov 22, 2021

Tried building my first App. Followed the Tutorial here

All went well until adding a Slash Command and then packaging the App. On using the rc-apps deploy Command the App breaks on packaging with following Error:

PS C:\Users\49179\VSCProjects\testapp> rc-apps deploy
   Starting App Deployment to Server

   Getting Server Info... ✓
   Packaging the app... -
 > ../../AppData/Roaming/npm/node_modules/@rocket.chat/apps-cli/node_modules/@rocket.chat/apps-compiler/bundler/esbuild.js:47:92: error: [plugin: apps-engine] The "path" argument must be of type string. Received undefined
    47 │                         if (!/@rocket\.chat\/apps-engine/.test(args.path) && path_1.default.isAbsolute(nodeModulePath)) {
       ╵                                                                                             ^
    at validateString (internal/validators.js:120:11)
    at Object.isAbsolute (path.js:353:5)
    at C:\Users\49179\AppData\Roaming\npm\node_modules\@rocket.chat\apps-cli\node_modules\@rocket.chat\apps-compiler\bundler\esbuild.js:47:93
    at callback (C:\Users\49179\AppData\Roaming\npm\node_modules\@rocket.chat\apps-cli\node_modules\esbuild\lib\main.js:814:34)
    at handleRequest (C:\Users\49179\AppData\Roaming\npm\node_modules\@rocket.chat\apps-cli\node_modules\esbuild\lib\main.js:646:36)
    at handleIncomingPacket (C:\Users\49179\AppData\Roaming\npm\node_modules\@rocket.chat\apps-cli\node_modules\esbuild\lib\main.js:701:7)
    at Socket.readFromStdout (C:\Users\49179\AppData\Roaming\npm\node_modules\@rocket.chat\apps-cli\node_modules\esbuild\lib\main.js:578:7)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:295:12)
    at readableAddChunk (_stream_readable.js:271:9)

   ../../AppData/Roaming/npm/node_modules/@rocket.chat/apps-cli/node_modules/@rocket.chat/apps-compiler/bundler/esbuild.js:35:26: note: This error came from the "onResolve" callback registered here   
    35 │                     build.onResolve({ filter: /.*/ }, async (args) => {
       ╵                           ~~~~~~~~~
    at setup (C:\Users\49179\AppData\Roaming\npm\node_modules\@rocket.chat\apps-cli\node_modules\@rocket.chat\apps-compiler\bundler\esbuild.js:35:27)
    at handlePlugins (C:\Users\49179\AppData\Roaming\npm\node_modules\@rocket.chat\apps-cli\node_modules\esbuild\lib\main.js:738:23)
    at Object.buildOrServe (C:\Users\49179\AppData\Roaming\npm\node_modules\@rocket.chat\apps-cli\node_modules\esbuild\lib\main.js:1026:7)
    at C:\Users\49179\AppData\Roaming\npm\node_modules\@rocket.chat\apps-cli\node_modules\esbuild\lib\main.js:1801:17
    at new Promise (<anonymous>)
    at Object.build (C:\Users\49179\AppData\Roaming\npm\node_modules\@rocket.chat\apps-cli\node_modules\esbuild\lib\main.js:1800:14)
    at Object.build (C:\Users\49179\AppData\Roaming\npm\node_modules\@rocket.chat\apps-cli\node_modules\esbuild\lib\main.js:1655:51)
    at AppsCompiler.bundleCompilation [as bundler] (C:\Users\49179\AppData\Roaming\npm\node_modules\@rocket.chat\apps-cli\node_modules\@rocket.chat\apps-compiler\bundler\esbuild.js:14:41)
    at AppsCompiler.bundle (C:\Users\49179\AppData\Roaming\npm\node_modules\@rocket.chat\apps-cli\node_modules\@rocket.chat\apps-compiler\AppsCompiler.js:41:45)

   LiftoffApp.js:5:26: note: The plugin "apps-engine" was triggered by this import
     5 │ const liftoff_1 = require("./commands/liftoff");
       ╵                           ~~~~~~~~~~~~~~~~~~~~
Error: Cannot find module './commands/liftoff'
Require stack:
- C:\Users\49179\VSCProjects\testapp/app.json
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
    at Function.resolve (internal/modules/cjs/helpers.js:78:19)
)
    at C:\Users\49179\AppData\Roaming\npm\node_modules\@rocket.chat\apps-cli\node_modules\@rocket.chat\apps-compiler\bundler\esbuild.js:46:58
    at callback (C:\Users\49179\AppData\Roaming\npm\node_modules\@rocket.chat\apps-cli\node_modules\esbuild\lib\main.js:814:34)
    at handleRequest (C:\Users\49179\AppData\Roaming\npm\node_modules\@rocket.chat\apps-cli\node_modules\esbuild\lib\main.js:646:36)
    at handleIncomingPacket (C:\Users\49179\AppData\Roaming\npm\node_modules\@rocket.chat\apps-cli\node_modules\esbuild\lib\main.js:701:7)
    at Socket.readFromStdout (C:\Users\49179\AppData\Roaming\npm\node_modules\@rocket.chat\apps-cli\node_modules\esbuild\lib\main.js:578:7)
    at Socket.emit (events.js:315:20)
  code: 'MODULE_NOT_FOUND',
  requireStack: [ 'C:\\Users\\49179\\VSCProjects\\testapp/app.json' ]
}
   Packaging the app... ✖
 »   Error:    ⟿  Build failed with 1 error:
 »   ../../AppData/Roaming/npm/node_modules/@rocket.chat/apps-cli/node_modules/@rocket.chat/apps-compiler/bundler/esbuild.js:47:92: error: [plugin: apps-engine] The "path" argument must be of type    
 »   string. Received undefined

Whenever I remove the part where it's extending the Configuration for the Slash Command everything runs well and get's uploaded to my test-server.

    protected async extendConfiguration(configuration: IConfigurationExtend): Promise<void> {
        await configuration.slashCommands.provideSlashCommand(new LiftoffCommand(this));
    }

The LiftoffCommand is 1:1 Copy from the Tutorial.

I am running this on:
@rocket.chat/apps-cli/1.10.1 win32-x64 node-v12.18.1

You can find a reproduction Repo here

@jayeshdesai4520
Copy link

@JNBG Hello, is there any fix? did you find it?

@JNBG
Copy link
Author

JNBG commented Feb 24, 2022

@jayeshdesai4520 so far no - but I didn't really find the time to work on it yet

@bk201-
Copy link

bk201- commented Apr 27, 2022

It seems I found a problemed code. It's in "bundler/esbuild.ts"

This function works on Linux, however doesn't work on Windows.

function normalizeAppModulePath(modulePath: string, parentDir: string): string {
    return /\.\.?\//.test(modulePath)
        ? path.resolve('/', path.dirname(parentDir), modulePath).substring(1).concat('.js')
        : modulePath;
}

@bk201-
Copy link

bk201- commented Jun 13, 2022

Hi!

Please see my PR that fixes this problem RocketChat/Rocket.Chat.Apps-compiler#47

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants