There was an error in the code: Unexpected token M

Is there a solution for this error that anyone can share?

The Google Developer Tools are not able to identify the exact location of the problematic code, making troubleshooting difficult.

I am using Meteor and MongoDB. I have looked into Unexpected tokens, finding A, N, C but M is less frequent.

I have come across suggestions that it could be related to a server commenting issue causing random letters and unrecognized scripts to appear.

Any advice on how to proceed?

Answer №1

Greetings from the ng-inspector maintainer (Apologies for not being able to leave a comment earlier)

I regret to hear about the troubles you faced with the extension. Just so you know, we have recently made an update (v0.5.8) to address exceptions related to the postMessage data.

Answer №2

Encountering the same troublesome issue, I found that it occurs specifically at line 1472 within ng-inspector.js where JSON.parse(eventData); is invoked.

Seemingly, the culprit lies in event.data containing a peculiar string starting with the letter 'M' - "Meteor._setImmediate.0.5014774943701923.5"

The following are the five lines preceding the JSON.parse() call in ng-inspector.js:

window.addEventListener('message', function (event) {

// Ensure the message was sent by this origin
if (event.origin !== window.location.origin) return;

var eventData = event.data;
if (!eventData || typeof eventData !== 'string') return;
eventData = JSON.parse(eventData);

Upon inspecting the event object in the debugger, the data property reveals:

event = MessageEvent {data: "Meteor._setImmediate.0.5014774943701923.5", origin: "http://localhost:3000", lastEventId: "", source: Window, ports:

Since ng-inspector.js functions as an Angular extension for Chrome, opting to uninstall it after transitioning to Meteor should resolve the issue.

An affirmation from another user confirms the remedy involves removing the Angular inspector Chrome extension, effectively resolving the problem.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Detect errors in the `valueChanges` subscription of Firestore and attempt a retry if an error occurs

My Angular app utilizes Firestore for storing data. I have a service set up to retrieve data in the following way: fetchCollectionColors(name) { this.db.collectionGroup('collection-colors', ref => ref.where('product', '==&ap ...

Exploring the concept of union types and typeguards in TypeScript

I'm struggling with this code snippet: function test(): any[] | string { return [1,2] } let obj: any[] = test(); When I try to run it in vscode, I get the following error message: [ts] Type 'string | any[]' is not assignable to type & ...

Clicking on an absolute HTML element will instantly scroll back to the top of the page

Working on a website, I've designed a custom menu that is hidden with 0 opacity and z-index -1. When a button is clicked, the menu will appear on the screen. You can visit to see the site in action. The issue I'm facing is that every time I cl ...

Execute an AJAX post request to the identical PHP page (utilizing the Jquery Form Plugin)

I am in the process of developing a new web interface using JavaTMP, an AJAX-based admin template. After spending time understanding its functionality, I have created a page with a form to allow users to create projects within my software. Typically, creat ...

Improper object handling

Within a waterfall function, there is a function that takes an array of user docs and determines if they represent the user or a friend of the user. The desired outcome is to return each user doc with a "me" value indicating true or false, and a "friend" v ...

Having trouble loading a CSV file into a static folder using Node.js and Express

As a newcomer to node and express, I am exploring the integration of d3 visualizations into my web page. Essentially, I have a JavaScript file that creates all the d3 elements, which I then include in my .ejs file. I am currently attempting to replicate a ...

The returned data from a Apollo Client useMutation call is consistently undefined

Currently, I have a code snippet that executes a mutation to update a post to "published." The mutation functions correctly and updates the data as intended. However, I am facing an issue where the data property remains undefined in the useMutation hook. S ...

Obtain the details of a selected item in a list by tapping on it using Natives

I am wondering how to retrieve the context of a tapped item in a listview. For example, if there are three items in the list, how can I determine that the second item was clicked and access the data related to that item in the observable array? For instan ...

Phaser 3 game app on iOS generated with Capacitor lacks audio functionality

I have developed a basic test app using Phaser 3 (written in Typescript and transpiled with rollup) and am utilizing Capacitor to convert it into an iOS application on my Mac. This excerpt highlights the key functionality of the app: function preload () { ...

How to Invoke JavaScript Functions within jQuery Functions?

I'm working on a jQuery function that involves dynamically loading images and checking their width. I have two JavaScript functions, func1() and func2(), that I want to call from within the jQuery function in order to check the width of each image. T ...

Error encountered: Unable to access attributes of an object that is not defined (specifically trying to read 'clientX')

Hey there! I'm having some trouble moving figures while moving the cursor. It's strange because I've done the same thing on another page and it worked perfectly: const scaleFactor = 1 / 20; function moveItems(event) { const shapes = do ...

Uncovering the enum object value by passing a key in typescript/javascript

How can I retrieve the value of an enum object by passing the key in typescript? The switch case method works, but what if the enum object is too long? Is there a better way to achieve this? export enum AllGroup = { 'GROUP_AUS': 'A' &a ...

ReactJS tables that can be filtered and sorted

Within my component's state, there exists an array named 'contributors'. Each element within this array is an object containing various properties. My goal is to present this data in a table format, with the added functionality of sorting an ...

How can I implement a for loop in Node.js?

I am currently experiencing an issue with my for loop while attempting to retrieve data from MongoDB and display it in the browser. The problem is that it only iterates through once, resulting in only the first entry being output. Strangely enough, when ...

Error encountered in Intellij for Typescript interface: SyntaxError - Unexpected identifier

I am currently testing a basic interface with the following code: interface TestInterface { id: number; text: string; } const testInterfaceImplementation: TestInterface = { id: 1, text: 'sample text' }; console.log(testInterface ...

Connecting with a php anchor and hash symbol in a website URL

Looking to include a PHP anchor along with a hash anchor in an HTML link. <?php echo '<a href="test.php?page='.$i.'#hash">'.$i.'</a>'; ?> The PHP code successfully echoes the link, but upon clicking it, th ...

Tips for locating a document in mongoose

Need help locating a specific userId in mongoose? Here is the code I am using: { _id: String, tagName: 'git', users: [ {userId: 1, count: 1} {userId: 234232342, count: 1} ] } I attempted to find the userId with the foll ...

What is the most efficient way to handle dependencies and instantiate objects just once in JavaScript?

I am interested in discovering reliable and tested design patterns in Javascript that ensure the loading of dependencies only once, as well as instantiating an object only once within the DOM. Specifically, I have the following scenario: // Block A in th ...

Sharing Global Variables in Node.js: What's the Best Way to Pass Them into Required Files?

Recently, I decided to organize my gulpfile.js by splitting it into multiple files within a /gulp folder. However, I encountered an issue when trying to pass a variable debug (boolean) into these files to control the behavior of the gulp command being incl ...

Validate if the JSON data array contains any elements

I'm currently working with an ajax code and I need to determine whether the JSON data contains an array or not. However, despite my attempts, I am still receiving incorrect output. $.ajax({ url: url, type: 'POST', da ...