Unable to deploy todo-app-custom-ui

I’m very new to Forge and started to work on tutorials and examples yesterday.

After successfully finished hello world examples for custom-ui, I tried to deploy todo-app-custom-ui example following the instruction in its readme. The build for static files was OK. But it fails with the error message below when I tried “forge deploy”.

I didn’t find any issue report similar to this. As you see, I’m trying on Windows 10 environment. Would someone help?

PS C:\Users\Username\forge\todo-app-custom-ui> forge deploy --verbose
Deploying your app to the development environment.
Press Ctrl+C to cancel.

Running forge lint...

Error: Cannot read property 'length' of undefined

TypeError: Cannot read property 'length' of undefined
    at Function.glob.hasMagic (C:\Users\Username\AppData\Roaming\npm\node_modules\@forge\cli\node_modules\glob\glob.js:110:30)
    at FileSystemReader.hasGlobSpecialChars (C:\Users\Username\AppData\Roaming\npm\node_modules\@forge\cli\node_modules\@forge\cli-shared\out\file-system\file-system-reader.js:56:23)
    at C:\Users\Username\AppData\Roaming\npm\node_modules\@forge\cli\node_modules\@forge\cli-shared\out\shared\read-app-config-files.js:13:30
    at Array.map (<anonymous>)
    at Object.exports.listGitIgnoreFiles (C:\Users\Username\AppData\Roaming\npm\node_modules\@forge\cli\node_modules\@forge\cli-shared\out\shared\read-app-config-files.js:12:82)
    at LintService.run (C:\Users\Username\AppData\Roaming\npm\node_modules\@forge\cli\out\service\lint-service.js:13:49)
    at DeployController.verifyPreDeployment (C:\Users\Username\AppData\Roaming\npm\node_modules\@forge\cli\out\command-line\controller\deploy-controller.js:29:56)
    at DeployController.run (C:\Users\Username\AppData\Roaming\npm\node_modules\@forge\cli\out\command-line\controller\deploy-controller.js:52:24)
    at C:\Users\Username\AppData\Roaming\npm\node_modules\@forge\cli\out\command-line\register-deployment-commands.js:14:50
    at Command.actionProcessor (C:\Users\Username\AppData\Roaming\npm\node_modules\@forge\cli\out\command-line\command.js:74:38)
PS C:\Users\Username\forge\todo-app-custom-ui>

Hi @SatoruNakata ,

I tried following the readme in the todo repo, and I also hit an error - although a bit different - when calling forge deploy from the root directory of the cloned repo. To resolve my error, I called npm install (also in the root directory), before calling forge deploy. The first npm install was for the frontend, the readme might’ve missed the second call before forge deploy. Do try it out and let us know how it goes.


Hello @iragudo

Thank you for your help. I tried your method but it didn’t work out well. (I tried forge deploy before and after your suggested “npm install”, I got the same error)

Though I found one walkaround. Renaming .gitignore file to something else. With this workaround, I could deploy the app to my environment.

After I look into the issue a little bit more, I found the issue occurs in glob.hasMagic function. And the glob object right before the error was as follows. It seems glob showed an error when it processes the first empty line. It may be the case that I’m on Windows 10 environment and it uses \r\n in the end of the line.

Glob {
  silent: false,
  pattern: '\r',
  strict: true,
  realpath: false,
  realpathCache: [Object: null prototype] {},
  follow: false,
  dot: false,
  mark: false,
  nodir: false,
  sync: false,
  nounique: false,
  nonull: false,
  nosort: false,
  nocase: false,
  stat: false,
  noprocess: true,
  absolute: false,
  maxLength: Infinity,
  cache: [Object: null prototype] {},
  statCache: [Object: null prototype] {},
  symlinks: [Object: null prototype] {},
  ignore: [],
  changedCwd: false,
  cwd: 'C:\\Users\\nakat\\forge\\todo-app-custom-ui',
  root: 'C:/',
  cwdAbs: 'C:/Users/nakat/forge/todo-app-custom-ui',
  nomount: false,
  minimatch: Minimatch {
    options: { noprocess: true, nonegate: true, nocomment: true },
    set: [],
    pattern: '',
    regexp: null,
    negate: false,
    comment: false,
    empty: true
  options: { noprocess: true, nonegate: true, nocomment: true },
  _didRealPath: false,
  matches: [],
  _processing: 0,
  _emitQueue: [],
  _processQueue: [],
  paused: false

But it seems forge’s read-app-config-files.js line 10 and 11 do use trim() to remove such spaces. I’m not so familiar with javascript so I wonder what’s going on. But anyway I will keep working on this to-do app since I can deploy it now.

    const gitignoreContents = ((_a = fileSystemReader
        .readFile(gitIgnorePath)) === null || _a === void 0 ? void 0 : _a.trim().split('\n').filter((glob) => glob !== '')) || [];


Thanks for your information on the problem. I was having the same issue and this helped. I actually changed the line endings on .gitignore to be just LF and it fixed the issue (in VS code it was just changing the CRLF in the bottom right to LF when editing .gitignore). This allowed it to still ignore all the built files and directories.

1 Like