I tried to use Match.ObjectIncluding in angular2-meteor1.3.1 project.
Based on this file meteor.d.ts, I can successful use
import { Meteor } from 'meteor/meteor';
import { Mongo } from 'meteor/mongo';
However, when I tried to use
import { Match } from 'meteor/match';
I got error:
/Users/hongbo-miao/.meteor/packages/meteor-tool/.1.3.1.z9fvfj++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/fibers/future.js:267
throw(ex);
^
Error: Can't find npm module 'meteor/match'. Did you forget to call 'Npm.depends' in package.js within the 'modules-runtime' package?
at Object.Npm.require (/test/.meteor/local/build/programs/server/boot.js:195:17)
at options.fallback (packages/modules-runtime.js:413:18)
at require (packages/modules-runtime.js:98:16)
at meteorInstall.collections.methods.ts (collections/methods.ts:2:1)
at fileEvaluate (packages/modules-runtime.js:158:9)
at require (packages/modules-runtime.js:92:16)
at /test/.meteor/local/build/programs/server/app/app.js:905:1
at /test/.meteor/local/build/programs/server/boot.js:283:10
at Array.forEach (native)
at Function._.each._.forEach (/Users/hongbo-miao/.meteor/packages/meteor-tool/.1.3.1.z9fvfj++os.osx.x86_64+web.browser+web.cordova/mt-os.osx.x86_64/dev_bundle/server-lib/node_modules/underscore/underscore.js:79:11)
How can I import Match correctly? Thanks
So it turns out the typings file is wrong. The new typings file is here, which uses
'meteor/check'
Related
I want to use pdfMake in deno and not host the pdfMake files and vfs_fonts on my server, by using a CDN line CDNJS or esm.sh.
I have the following code in the to of my app.js file:
import pdfMake from "https://esm.sh/pdfmake"
import * as pdfFonts from "https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.4/vfs_fonts.min.js"
but I get the following errors:
[!] [#0] starting `deno run -A app.js`
Download https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.4/vfs_fonts.js
Download https://deno.land/x/md5/mod.ts
error: Uncaught TypeError: Cannot read properties of undefined (reading 'pdfMake')
this.pdfMake = this.pdfMake || {}; this.pdfMake.vfs = {
^
at https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.2.4/vfs_fonts.js:1:21
[E] [daem] app crashed - waiting for file changes before starting ...
I am not sure how to import or load the vfs_fonts from the CDN. Please note that my aim is to use a CDN for getting pdfMake and it's fonts.
I've changed the app.js file so that I only load the pdfmake from the CDN. I then load the fonts seperatly from the CDN into the pdfMake object:
import pdfMake from "https://esm.sh/pdfmake"
pdfMake.fonts = {
Roboto: {
normal: 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.66/fonts/Roboto/Roboto-Regular.ttf',
bold: 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.66/fonts/Roboto/Roboto-Medium.ttf',
italics: 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.66/fonts/Roboto/Roboto-Italic.ttf',
bolditalics: 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.66/fonts/Roboto/Roboto-MediumItalic.ttf'
},
Merriweather: {
normal: 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.66/fonts/Merriweather/Merriweather-Regular.ttf',
bold: 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.66/fonts/Merriweather/Merriweather-Medium.ttf',
italics: 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.66/fonts/Merriweather/Merriweather-Italic.ttf',
bolditalics: 'https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.66/fonts/Merriweather/Merriweather-MediumItalic.ttf'
},
}
Here's my code:
// #flow
import { EntityModel } from '#http-utils/hateoas';
I compile it:
babel src/ -d dist/
Then I run it, but I get a runtime error:
$ node dist/http-utils-hateoas-example.js
import { EntityModel } from '#http-utils/hateoas';
^
SyntaxError: Unexpected token {
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
What am I doing wrong?
Edit
Based on Flow documentation, my babel config has only #babel/preset-flow. Looks like this is only stripping flow. How do I configure babel to do additional compilation down to code that can be run on nodejs?
{
"presets": [
"#babel/preset-flow"
]
}
The solution was very simple. All I needed was another preset to transpile down to CommonJS.
{
"presets": [
"#babel/preset-flow",
#babel/preset-env
]
}
In my Angular 5 project I want to implement google autocomplete geolocation.
I got some reference of npm modules:-
https://www.npmjs.com/package/ng4-geoautocomplete
https://www.npmjs.com/package/ngx-google-places-autocomplete
According to their guidance when I am going to install that module I am facing some warning:
Installation command:-
npm install --save ng4-geoautocomplete
Warnings:-
***npm WARN ngx-slideshow#0.1.0 requires a peer of #angular/core#^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ngx-slideshow#0.1.0 requires a peer of #angular/common#^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ng4-geoautocomplete#0.1.0 requires a peer of #angular/core#>=2.0.0 <5.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ ng4-geoautocomplete#0.1.0
added 68 packages in 96.971s***
My project version:-
Angular CLI: 1.7.4
Node: 8.9.3
OS: win32 x64
Angular: 5.2.10
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
#angular/cli: 1.7.4
#angular-devkit/build-optimizer: 0.3.2
#angular-devkit/core: 0.3.2
#angular-devkit/schematics: 0.3.2
#ngtools/json-schema: 1.2.0
#ngtools/webpack: 1.10.2
#schematics/angular: 0.3.2
#schematics/package-update: 0.3.2
typescript: 2.5.3
webpack: 3.11.0
Why I am facing this problem and what will be the solution?
Is there any other way to implement google autocomplete geolocation?
Yes.
npm install #agm/core --save-dev
npm install #types/googlemaps --save-dev
app.module.ts
import {AgmCoreModule} from '#agm/core'
.
.
.
imports: [
.
.
.
AgmCoreModule.forRoot({
apiKey: 'your api key',
libraries: ['places']
}),
.
.
.
]
in your html
<div>
<input type="text" placeholder="Search for location" autocorrect="off" name="" spellcheck="off" #autoSearch/>
</div>
component.ts file
import {Component, ViewChild, ElementRef, NgZone, OnInit} from '#angular/core'
import { MapsAPILoader } from '#agm/core';
import {} from #types/googlepmaps;
.
.
.
export class YourComponent implements OnInit {
#ViewChild('autoSearch') public searchElement: ElementRef;
consturctor (private mapsAPILoader: MapsAPILoader , private ngZone : NgZone )
{}
ngOnInit() {
this.mapsAPILoader.load().then(
() => {
let autocomplete = new
google.maps.places.Autocomplete(this.searchElement.nativeElement,
{types:["address"]});
autocomplete.addListener("place_changed", ()=> {
this.ngZone.run(()=>{
let place: google.maps.places.PlaceResult =
autocomplete.getPlace();
if(place.geometry === undefined || place.geometry === null) {
return;
}
})
})
}
);
}
}
I rather use the AGM library rather than just the autocomplete that you are using because the autocomplete only gives you autcomplete fucntionalty whether the AGM can be use to render the google maps with the markers.
Now,
to install dependencies yourself to fix your warnings you can reference to this stackoverflow question: How to install npm peer dependencies automatically?
I'm getting this error in my vuejs webApp, hope some one tell me how to solve it:
./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?
type=script&index=0!./src/components/Envio.vue
Module not found: Error: Can't resolve './firebase' in
'C:\Users\#####\Desktop\#####\src\components'
# ./node_modules/babel-loader/lib!./node_modules/vue-loader/lib/selector.js?
type=script&index=0!./src/components/Envio.vue 17:0-32
# ./src/components/Envio.vue
# ./src/routes.js
# ./src/main.js
# multi (webpack)-dev-server/client?http://localhost:8080 webpack/hot/dev-
server ./src/main.js
this is the script in my vue file:
<script>
import { db } from './firebase'
export default {
data: {
mensaje: null,
... }
}
</script>
I assume you have installed firebase via a node package manager using npm command. If so, the following import statement should fix the problem.
import { db } from 'firebase'
We are working on a universal app, that must execute on mobile (ios, android), desktop (windows, mac, linux) adn in any browser.
For client database management, we want to use sqlite3 - for desktop- , in this case the app will be packaged using Electron (Atom shell) . The module bundler we are using is webpack, as the app is developed with Ionic 2 and Angular2.
We have installed sqlite3 well, as a project dependency, with node-pre-gyp generating the binary for the platform (in this case we are testing with Windows 7 64 bits)
We have a provider for Sqlite3, this is the code:
import * as sqlite3 from 'sqlite3';
import { IDatabaseProvider } from './database.provider';
export class Sqlite3DatabaseProvider implements IDatabaseProvider {
private _storage;
constructor() {
console.log('Initializing Sqlite3 Database Provider');
}
openDatabase() {
this._storage = new sqlite3.Database('v2App_sqlite3.db');
}
}
As you can notice, the line the creates a database is commented, as the app works OK like that. If I uncomment that line , we have this error:
Runtime Error
Cannot read property '_handle' of undefined
TypeError: Cannot read property '_handle' of undefined
at http://localhost:8100/build/main.js:210758:15
at Array.forEach (native)
at module.exports (http://localhost:8100/build/main.js:210757:36)
at Object.<anonymous> (http://localhost:8100/build/main.js:12580:1)
at Object.<anonymous> (http://localhost:8100/build/main.js:12873:30)
at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
at Object.<anonymous> (http://localhost:8100/build/main.js:69457:11)
at Object.<anonymous> (http://localhost:8100/build/main.js:69638:30)
at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
at Object.<anonymous> (http://localhost:8100/build/main.js:211548:72)
The curious of this, is that it's failing here, in the code of the set-blocking npm module:
module.exports = function (blocking) {
[process.stdout, process.stderr].forEach(function (stream) {
if (stream._handle && stream.isTTY && typeof stream._handle.setBlocking === 'function') {
stream._handle.setBlocking(blocking)
}
})
}
As stream is coming undefined ,when getting the _handle property gives the error.
But this code is only executed if I add the line that creates the sqlite3 database:
this._storage = new sqlite3.Database('v2App_sqlite3.db');
What is the relation between this module (set-blocking ) and sqlite3 ?, Why the streams are undefined when trying to create the sqlite3 database ?
Maybe as generates a file - the database - , using Node's outputStream, and still could not have been created that object - stream.
Any help?
Thanks in advance