question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple warnings: Could not load worker TypeError: e.split is not a function

See original GitHub issue

Please how can I mute the multiple warning messages in the console. I assume the setMode ivocation is the direct cause of it. How should I rephrase my code so that is goes silent? Below please find my code.

console.(anonymous function)	@	console.js:26
o	@	VM41567:1
$startWorker	@	VM41567:1
$onChangeMode	@	VM41567:1
setMode	@	VM41567:1
AceEditorComponent.setMode	@	component.ts:82
AceEditorComponent.init	@	component.ts:35
AceEditorComponent	@	component.ts:28
Wrapper_AceEditorComponent	@	wrapper.ngfactory.js:7
View_ContentPageComponent0.createInternal	@	component.ngfactory.js:210
AppView.create	@	view.js:74
DebugAppView.create	@	view.js:327
View_ContentPageComponent_Host0.createInternal	@	host.ngfactory.js:16
AppView.createHostView	@	view.js:81
DebugAppView.createHostView	@	view.js:338
ComponentFactory.create	@	component_factory.js:154
ViewContainerRef_.createComponent	@	view_container_ref.js:113
RouterOutlet.activate	@	router_outlet.js:98
ActivateRoutes.placeComponentIntoOutlet	@	router.js:899
ActivateRoutes.activateRoutes	@	router.js:873
(anonymous function)	@	router.js:828
ActivateRoutes.activateChildRoutes	@	router.js:828
ActivateRoutes.activateRoutes	@	router.js:860
(anonymous function)	@	router.js:828
ActivateRoutes.activateChildRoutes	@	router.js:828
...

for brevity: snipped repetitive calls from Observable and zone

html

<ace-editor #editor
                  class="code-editor"
                  mode="html"
                  theme="clouds"
                  [text]="(buildHtml$ | async)"
                  [readOnly]="!(editorInitialized$ | async)"
                  [autoUpdateContent]="false"
                  (textChanged)="onCodeChange($event)"
      ></ace-editor>

ts

private editorOptions: any = {
    showPrintMargin: false,
    showInvisibles: true,
    highlightGutterLine: false,
    highlightActiveLine: false,
    fadeFoldWidgets: true,
    showLineNumbers: true,
    showGutter: true,
    fontSize: 16,
    wrap: false,
  };

const editor = this.editor.getEditor();
editor.$blockScrolling = Infinity; // needed to suppress component's debug message
editor.setOptions(this.editorOptions);

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:15

github_iconTop GitHub Comments

7reactions
fgladischcommented, Mar 13, 2017

This is working for me:

import { Component } from '@angular/core';
import 'brace/theme/github';
import 'brace/mode/json';

@Component({
  selector: 'my-editor',
  template: '<ace-editor theme="github" mode="json"></ace-editor>'
})
export class MyEditorComponent {}

Maybe some info in the README would be useful. I didn’t even know this was using brace until @Jinnie’s comment. Thanks.

1reaction
wesleyyoungcommented, Apr 24, 2018

you don’t need to add

"../node_modules/ace-builds/src-min/ace.js"

to your scripts array in angular-cli.json. If it’s there take it out.

add this to the top of your ace-editor component.ts

import * as ace from 'brace';

plus

import 'brace/mode/javascript';
import 'brace/theme/monokai';

for every theme and mode you want.

Then make your export class look something like this:

export class YourComponent implements OnInit {

  public editor;

  private options: any = {
      showPrintMargin: false,
      showInvisibles: true,
      highlightGutterLine: false,
      highlightActiveLine: false,
      fadeFoldWidgets: true,
      showLineNumbers: true,
      howGutter: true,
      fontSize: 16,
      wrap: false,
      mode: 'ace/mode/javascript'
  };

  constructor() { }

  ngOnInit() {
      this.editor = ace.edit('editor');
      this.editor.getSession().setMode('ace/mode/javascript');
      this.editor.setTheme('ace/theme/monokai');
      this.editor.setOptions(this.options);
      this.editor.$blockScrolling = Infinity;
      this.editor.setValue([

          '// JavaScript',

          'var a = 3;',

          '// below line has an error which is annotated',

          'var b ='

    ].join('\n'));
    this.editor.clearSelection();
  }
}

the element should be rendered and watched by brace without any errors

NOTE:

For some reason brace won’t detect the <ace-editor #editor></ace-editor> directive as it stands in your comment. You have to change it to <div ace-editor id="editor"></div>

ALSO !

make sure you are not importing import { AceEditorModule } from 'ng2-ace-editor'; in your app.module.ts as it will overwrite brace and not allow you to set the mode or other options

Read more comments on GitHub >

github_iconTop Results From Across the Web

TypeError: u.split is not a function - javascript - Stack Overflow
You're passing messages as an array, not as a string. Change your code to db.collection("groups").doc(groupId).collection("messages").add({ ...
Read more >
TypeError: split is not a function in JavaScript | bobbyhadz
The "split is not a function" error occurs when we call the split() method on a value that is not of type string....
Read more >
JavaScript Errors and How to Fix Them - David Walsh Blog
JavaScript can be a nightmare to debug: Some errors it gives can be very difficult to ... Uncaught TypeError: undefined is not a...
Read more >
Firebase JavaScript SDK Release Notes - Google
Cloud Firestore. Fixed a bug that caused Uncaught TypeError: e.auth.addAuthTokenListener is not a function . See GitHub ...
Read more >
Fixed - Uncaught TypeError: a.replace is not a function
appBadgeUpdate() . This does assume that newCount is a string, but this might not necessarily be the case - on initial page load...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found