Meteor: jQuery is not defined - meteor

I am having a problem with using jQuery in my Meteor app. It is undefined.
When I look inside .meteor/versions, I can clearly see:
jquery#1.11.3_2
But when I type $ or jQuery in my Chrome console, I get undefined. Also, I cannot use external packages that use any jQuery; I get undefined is not a function exception.
Manually adding jQuery package by meteor add jquery did not solve the issue.
Any idea why this happens?

jQuery is inside the meteor core and defined as a dependency inside meteor-platform. So I never declare it as a a dependency. Meteor relies heavily on it, so it's unlikely to ever be removed. Unlike underscore, which they stated they will remove in a future release. Meteor always aliases $. So that should work. It can't be an issue with that specific version. I'm running the same without any issues. Here are some things you could try to debug:
Create a new project and check if JQ works
Check if an installed package is causing the problem (by removing them one by one)
Packages get loaded before your code, so that can't be the problem.

Related

Using "UNSAFE_componentWillMount" in strict mode. But I'm not sure where the issue is

I have a Next.js application that when run, gives me this issue on the browsers console.
Warning: Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. See https://reactjs.org/link/unsafe-component-lifecycles for details.
* Move code with side effects to componentDidMount, and set initial state in the constructor.
Please update the following components: SideEffect(NullComponent)
I am not sure what SideEffect(NullComponent) is and searching through all the text in my project returns no result. So I'm not sure where the problem is coming from in order to try and resolve it, or be able to provide some relevant code in here.
What does this error mean, and how can I locate at least what file is causing the issue?
The error that you see is most likely the be in a package that you are using
Try to search for the whole project (including node_modules folder) or look more carefully in the console error (name of the file that generates the error).
This way you will know which package uses the outdated code and decide to keep it or update it or use another similar package.
To search for the whole project including node_modules

Ionic using PounchDB fail

I`m testing PounchDB for my new app and, i receive this error when try execute this code:
PouchDB.plugin(require('pouchdb-adapter-cordova'));
_db = new PouchDB('mydb.db', {adapter: 'cordova-sqlite'});
Erro received:
ReferenceError: Can't find variable: require
I follow instructions from: https://github.com/nolanlawson/pouchdb-adapter-cordova-sqlite
Using ionic 1.
You're using require without an associated package manager or module bundler. require is not native to JavaScript -- you have to include a library or package your app in order for this to work.
I suggest JSPM (http://jspm.io), since it works with SystemJS and supports the newest ES2015 module syntax. However, it also understands require.
Alternatively, you can use Browserify(http://browserify.org) to bundle your code (essentially Browserify packs everything into one file, which is great for production!). Webpack(https://webpack.github.io) is also a great option. Both of these will add a build step to your development workflow, so be aware of that (but you should have one anyway).

Typescript Promise duplicate issue

I have been having a heck of a time getting es6 promises to work with Typescript in a ASP.NET 5 project. I installed the es6-promise.d.ts via tsd install es6-promise. However, I get errors about Promise being duplicated. When I hover on the Promise declaration in the es6-promise.d.ts file, I get the error below (see the blue section ac the bottom of the image). It seems to be conflicting with some typescript definition file from a Microsoft SDK, which is obviously not part of my project.
Does anyone have an idea on why this might be happening or how I can fix this?
What version of TypeScript are you using?
Promise is declared in lib.es6.d.ts.
Check your --target option for tsc. If it is equal to es6 then I think you reference the promise definition twice because one is part of tsc compiler.

Running meteor project on a newer version

Five months ago I created a project using meteor windows version 0.5.x, project works great on that version of meteor, but today, when I migrated to version 0.6.4.1 I had problems with the functionality of the project, three functions from model.js loss reference in client.js call (undefined functions).
Exception from Deps recompute: ReferenceError: displayName is not defined
(but, this function is defined in model.js)
I noticed, from browser console that every function of the model lose reference in client.js.
I tried to run the project using the command
meteor --release 0.5.x
but every try to run I get the error "Can't specify a release when running meteor from a checkout".
What would be the problem for undefined reference functions (in the release of newer version).
Meteor 0.6.x changed variable scoping across multiple files : each source file is encapsulated inside an anonymous function making its local var/function declarations visible only to the concerned file.
To enable exporting symbols and reference them in other files, you now have to use this syntax :
myVar=value;
// instead of
var myVar=value;
myFunc=function(){...};
// instead of
function myFunc(){...}
If you did something like
function displayName(){...}
in model.js, try replacing it with
displayName=function(){...};
I'm pretty sure it will do the trick.

Using Handlebars util methods in Meteor server

I'm working on my first Meteor app, and I'm trying to escape a string on the server side. I was hoping to use Handlebars.Utils.escapeExpression, but even when I add handlebars (which I had to do, even though Meteor already uses it?), I still get
ReferenceError: Handlebars is not defined
error when that code is hit. Is there a way to invoke that method server side without manually including the source in my project?
Meteor uses Handlebars on the client only. Server-side rendering is on the roadmap.
Also, the Handlebars that comes with Meteor doesn't include Utils.
Use {{{thingThatNeedsEscaping}}} instead, as per the documentation that unescapes it.
Also, I don't think it's necessary to escape stuff before inserting it into the database, if you want it though there are other JS functions for that (like escape variants that are not deprecated).

Resources