How to edit Meteor package source files?

Hi!

I’m using StubCollections for some unit tests. The package works successfully while running the tests in my console. However, I cannot get them to run in my browser because of some syntax errors in the source file itself.

I get Uncaught SyntaxError: Unexpected token '*'

The error is at the end of the file for a function that looks to have been commented out.

function get(object, pathI
 * //tOg.get(object, [gglobal;

/*ues.
 0].b.c(

I added an Issue to the package’s repo but haven’t heard back yet.

Since this is just used for running tests in dev mode, I was hoping I could get into the source file itself and just delete that function. I did some poking around and could not find the actual file.

Where are meteor packages actually stored ?

I think you can create a packages folder under the root of your project. Inside it you can checkout the package you want to change from github. Your ‘local’ version will take precedence over the installed one.

1 Like

If you look at the source of StubCollections: https://github.com/hwillson/meteor-stub-collections/blob/master/index.js
The offending function and comment doesn’t appear at all.

So it’s likely either a build error, which can be fixed with meteor reset,
or it’s another package that has the error.

Can you see if meteor reset fixes the issue? (warning, this will clear your development database)

And if that doesn’t fix it, can you post the full error with stack trace and the name and contents of the compiled file?

2 Likes

No dice with meteor reset. The console error that I get is Uncaught SyntaxError: Unexpected token '*' for the file ‘http://localhost:3000/packages/hwillson_stub-collections.js?hash=8ec659b920c90416399f8f1f11485b19e3dc743e’ .

It does seem like a build error. I’m noticing the actual file contains over 5000lines. But the actual StubCollections segment ends around Line137.Then there’s a lot of lines for what looks like StubCollections’ dependencies.

https://pastebin.com/W18dmUq1 is a link to the source. Any idea what’s going on and what could’ve caused this? Thanks!

If you scroll up to line 4616, you can see the comment block where the original file came from:

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//                                                                                                                     //
// node_modules/meteor/hwillson_stub-collections/node_modules/lodash.get/index.js                                      //
//                                                                                                                     //
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

I just checked in my project and lodash.get is included correctly :man_shrugging:

What version of StubCollections are you using?
I’m using 1.0.9

Might be worth clearing Meteor’s global package cache by deleting the folder at ~/.meteor/packages/ and ~/.meteor/pacakge-metadata.
Then do a meteor reset and run again
That will force meteor to download fresh copies of every package

So what exactly is that big 5k Line file? Is it the source for StubCollection, but then also its dependencies…hence the lodash, sinon, etc…

I’m also using version 1.0.9.

I’m using Windows and deleting ~/.meteor/packages/ just cleared my whole packages file and ~/.meteor/pacakge-metadata didn’t even exist. However, upon clearing ~/.meteor/packages/ and running meteor reset I was unable to start the app. I had to put my packages in just to get it to run again.

I then switched to another branch that didn’t have StubCollections in my packages and re-installed it. Upon reinstalling I still got the same error. Seems like something logistical here, I’ll clone another machine, rebuild, and see if it works from there

Oh sorry, then the location of the global cache is different. It’s in
C:\Users\yourUserName\AppData\Local\.meteor\

On *nix ~/ is a shortcut to the home folder, so different to the .meteor in your app which is why removing packages didn’t work for you

I deleted everything in .meteor but now get 'meteor' is not recognized as an internal or external command, operable program or batch file. everytime I try to run a meteor command. Friggin windows.
Any idea what would’ve caused this, I thought I deleted just the cache? Seems the bin must’ve been in there too. Looks like I might have to re-install

Got Meteor up and running through a re-install. Ran the app again which forced the packages to get installed again too.

I’m shockingly still getting the same error. Must be some kind of logistical error with my machine. I’m gonna try on another one

Ahh I forgot that the meteor bin actually lives in AppData/local/.meteor/packages/meteor-tool/

Sorry I gave advice that wasted your time. Especially when it didn’t solve your problem :sob:

No need to apologize! Still learned a lot. You’re always extremely helpful