Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Unexpected token in map file (node) #5649
I'm using node and express and when I build certain files then I get this error:
This makes the app break and not work.. I don't really know what the issue is as there is nothing special about the file and it has happened on other files before. Have you seen this issue before? At this point the only option I have is to change the file back to being a .js file and not use typescript there. I am compiling using grunt-ts task but I don't think that is the issue... I could be wrong.
Basically I have an express application that I have just recently converted to use TS and some specific files for example this file
When compiles creates a .js.map file that is being run presumably by node when the app is running (for debugging using VSCode). The Mapp file looks liek this:
As far as I can tell there is little difference between thsi map file and any other map file in the project and I have map files being created for everything...
What specific further information do you need? This is the debug stack trace:
Sorry I'm not sure what else I can really provide without giving you access to the code. If you can't figure it out I will try to reproduce with a simple version of what I am doing.
Thanks for you help!
the .map files are used by the debugger, they are not executable. the file you should pass to node is your .js file, just like you would without typescript.
the .js file has a comment at the bottom that tells the debugger about the .map file. the debugger then loads the .map file.
you can find more information about source maps at: http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/
if you do not want to have source maps generated, do not pass the
Yes i understand how it works and i do want the map file so i can debug. Howver this error occurs when just including the index.js file generated from the above index.ts file. I am not manually including the map file. That is, as far as i can tell, node throwing an error when trying to intepret the map file.
I cant see anyway in my code that the map file is being included i am including the index.js from my app.js with
I will try to repoduce in a simple repo tomorrow.
My apologies! after trying to reproduce I discovered what the issue was. Due to the implementation in the code above I was i fact executing the map file as you said. Therefore it was throwing an error. I have fixed this now because I was doing some file reading and I needed to exclude the .map AND the .ts files from the results.
Thanks for you help! If you would like to see what I am talking about I have created a repo here which I might flesh out more when I have time showing people how to create a Sequelize structure for your files using ts:
Its very basic and doesn't really use any Typescript yet but shows how you would change their code to not break like it did for me.
Once again this had nothing to do with Typescript and my apologies!
I ran into this today, so I thought I'd share the answer for future typescript/sequelize migrators!
Most likely you followed a fairly common Sequelize code example which load all models from a directory, without checking explicitly for