error when loading aurelia-validation plugin - javascript

I am trying to setup aurelia-validation plugin in my project. I am using VS2015.
I have installed aurelia-validation plugin using jspm install aurelia-validation command.
Config.js file has been updated "aurelia-validation": "github:aurelia/validation#0.2.7"
and in jspm_packages/github I see validation#0.2.7 folder.
I have added a plugin in my main.js file.
export function configure(aurelia) {
aurelia.use
.standardConfiguration()
.developmentLogging()
.plugin('aurelia-validation');
aurelia.start().then(a => a.setRoot());
}
and have changed my aurelia-app to aurelia-app="main"
When I start the app I get the following error in Firefox console:
Unhandled promise rejection TypeError: aurelia.globalizeResources is not a function
Stack trace:
configure#http://localhost:15724/jspm_packages/github/aurelia/validation#0.2.7/index.js:28:5
loadPlugin/<#http://localhost:15724/jspm_packages/github/aurelia/framework#0.15.0/aurelia-framework.js:34:32
run#http://localhost:15724/jspm_packages/npm/core-js#0.9.18/modules/es6.promise.js:91:43
notify/<#http://localhost:15724/jspm_packages/npm/core-js#0.9.18/modules/es6.promise.js:105:11
module.exports#http://localhost:15724/jspm_packages/npm/core-js#0.9.18/modules/$.invoke.js:6:25
#http://localhost:15724/jspm_packages/npm/core-js#0.9.18/modules/$.task.js:40:9
run#http://localhost:15724/jspm_packages/npm/core-js#0.9.18/modules/$.task.js:27:7
listner#http://localhost:15724/jspm_packages/npm/core-js#0.9.18/modules/$.task.js:31:5
I have tried clearing jspm cache with jspm cc command but that didn't help. All my packages are up to date.
What am I missing?
Thank you.

There was a breaking change in Aurelia 0.15.0:
In the commit fix(all): create a property framework configuration object
the globalizeResources method was renamed to globalResources
Since then (2015.08.13) the aurelia-validation plugin hasn't been updated.
You get the error because the aurelia-validation only supports aurelia 0.14.1 or older. So you have to downgrade your aurelia version to work with the validation plugin until it is not updated.

The accepted answer is correct. A quick fix (to avoid downgrading aurelia) would be to manually edit this line:
https://github.com/aurelia/validation/blob/master/dist/system/index.js#L10
in your jspm_packages\github\aurelia\validation... folder
Also change any aurelia.withSingleton calls to aurelia.container.registerSingleton

Related

How can I resolve a TypeError using old version of ember and ember-light-table?

I have the test project at https://github.com/ericg-ember-questions/test_computed_sort
I setup the project by doing the following:
Node version: v12.18.1 (npm v6.14.5)
npm install --save-dev ember-cli#3.4
./node_modules/.bin/ember new test_computed_sort
cd test_computed_sort/
./node_modules/.bin/ember install ember-light-table#1.13.2
./node_modules/.bin/ember generate component test-comp
./node_modules/.bin/ember serve
application.hbs
{{test-comp}}
test-comp.hbs
Hello
{{#light-table}}
{{/light-table}}
If I comment out the reference to light-table, no error is generated. However, with it, I see in the console:
media.js:15 Uncaught TypeError: decorator is not a function
at media.js:15:1
at Array.reduce (<anonymous>)
at _applyDecoratedDescriptor (media.js:15:1)
at Module.callback (media.js:240:1)
at Module.exports (loader.js:106:1)
at Module._reify (loader.js:143:1)
at Module.reify (loader.js:130:1)
at Module.exports (loader.js:104:1)
at requireModule (loader.js:27:1)
at Class._extractDefaultExport (index.js:432:1)
What can I do to resolve this error so I can use ember-light-table with this project?
The error kinda hints at this, but it doesn't really make sense unless you're using modern ember -- but you're using 3.4 (thanks for providing that information!!)
The stack in your error is actually very helpful, and here's how you can figure out what the issue is.
I downloaded your reproduction repo (thanks for providing that! reproductions are immensely helpful in debugging!)
I got the same error you did:
The key piece here is the media.js reference.
Clicking into that we see:
that the compiled version of the ember-responsive/services/media file is using decorators --
you have some version of ember-responsive in your app which has decorators.
I saw in your package.json that you're specifying on alder version:
"ember-responsive": "^4.0.2",
this v4 version of ember-responsive only supports ember 3.13 and higher.
Kinda poking around the ember-responsive github, https://github.com/freshbooks/ember-responsive/blob/v3.0.5/config/ember-try.js
I see that the v3 series of ember-responsive supports back to Ember 2.12 -- definitely before decorators before supported.
So downgrading ember-responsive and restarting the app reveals this error:
"Assertion Failed: [ember-light-table] table must be an instance of Table"
this error is documented here: https://github.com/adopted-ember-addons/ember-light-table/issues/726
so it looks like some APIs usage issue.
If you want help figuring that out, feel free to post another question.

Could not find a declaration file for module 'react/jsx-runtime'

I am using material-ui in react with typescript template. All of my code is working fine but I am getting this error on multiple lines (not an error warning but with red line as my code renders)
Could not find a declaration file for module 'react/jsx-runtime'. 'C:/Users/dell/Desktop/Web current Projects/typescript/card/node_modules/react/jsx-runtime.js' implicitly has an 'any' type.
If the 'react' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react`ts(7016)
As per #NearHuscarl's comment, a quick fix is to create your own declaration module for react/jsx-runtime. You can do this by opening the react-app-env.d.ts file (created by default when you use create-react-app), found in your project's root directory. Then add the following script to it:
declare module "react/jsx-runtime" {
export default any;
}
The create-react-app team don't believe this is an issue for create-react-app to solve, and suggest it's a problem with typescript version 4. So alternatively you can downgrade your typescript version until the typescript team provide a fix in a later version.
Try restarting vscode and see if it got fixed
When you have this error, it is usually because you installed a library and you didn't install the types of that library.
To fix this error, you need to install #types/library-name using your package manager (npm or yarn).
Came across this when trying to use create-react-app with typescript.
What solved it for me was changing the following file:
react-app-env.d.ts
/// <reference types="react-scripts" />
declare module 'react/jsx-runtime' {
const content: string;
export default content;
}
use yarn for manage package.
run this command
yarn install

Run Android Failed reason package android.support.v4.net does not exist [duplicate]

I updated 'android.support:appcompat-v7' to 28.0.0.
But it brought an error from the build.
Attribute application#appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:8:5-23:19 to override.
Then I get this error in my Logcat:
Manifest merger failed
my app.gradle:
configurations.all {
resolutionStrategy.force 'com.android.support:design:28.0.0'
resolutionStrategy.force "com.android.support:support-v4:28.0.0"
resolutionStrategy.force "com.android.support:support-media-compat:28.0.0"
}
...
dependencies {
implementation 'com.android.support:multidex:1.0.1'
// Our dependencies
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
}
how do I fix it?
I need your solutions.
Thank you in advance.
Upgrading 'react-native-device-info' to version 2.1.2 fixed the error for me. See github.com/facebook/react-native/issues/25294#issuecomment-503024749
In short: the library used "services-gcm:+" as a dependency, and the latest gcm version caused this problem.
The root cause is related migration to Androidx, google play service updated to androidX
Thanks to MR03web This problem belongs to react-native-device-info? best option is to upgrade react-native-device-info using
yarn upgrade react-native-device-info#2.1.2
cd android && gradlew clean
react-native run-android
or if you don't want to upgrade you should exclude com.google.android.gms from react-native-device-info like this. Thanks
implementation(project(":react-native-device-info"), {
exclude group: "com.google.android.gms"
})
implementation "com.google.android.gms:play-services-gcm:16.0.0"
Add the following to your gradle.properties then clean/rebuild
googlePlayServicesVersion=16.1.0
firebaseVersion=17.6.0
I found a solution through my search by referring to #MehulSolanki answer.
I add
tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"
in my on AndroidManifest.xml
and update com.android.tools.build:gradl:
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'
}
And add this in your gradle.properties file
android.useAndroidX=true
android.enableJetifier=true
ERROR: [TAG] Failed to resolve variable '${animal.sniffer.version}'
ERROR: [TAG] Failed to resolve variable '${junit.version}'
In case of above error
File -> Invalidate Caches / restart
Build -> Clean project
error: package android.support.annotation does not exist
error: cannot find symbol class Nullable
In case of above error
Add implementation 'androidx.annotation:annotation:1.1.0'
change import android.support.annotation.Nullable; => androidx.annotation.Nullable;
change import android.support.annotation.NonNull; => androidx.annotation.NonNull;
Compile version and target version should be 28.
Add 'tools:replace="android:appComponentFactory"' in your AndroidManifest.xml inside <application> tag
Your AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="ru.chopcode.myapplication">
<application
tools:replace="android:appComponentFactory"
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:roundIcon="#mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="#style/AppTheme">
</application>
Downgrade Google Play service version. In android/app/build.gradle change
compile 'com.google.android.gms:play-services-<service_name>:+'
to
compile 'com.google.android.gms:play-services-<service_name>:16.0.0'
So in my case < sevice_name > was location. But in someone's else case it may be any other Google Play Service (like in list here http://www.androiddocs.com/google/play-services/setup.html).
After spending a whole day on this issue. Finally, I have resolved this issue.
I got that error from react-native-device-info and react-native-fast-image library.
I just remove that library from package.json file and then install
"react-native-device-info": "^2.1.2",
"react-native-fast-image": "^6.0.3" this latest version
I have used below gradle version
classpath 'com.android.tools.build:gradle:3.3.1'
I have used below properties version
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
I have used below versions
buildToolsVersion = "28.0.3"
minSdkVersion = 16
compileSdkVersion = 28
targetSdkVersion = 28
supportLibVersion = "28.0.0"
This answer should help most people. If it still does not then the way to solve this (which is not that good) is that you open the android project in android studio. That should fetch all the gradle files. On the right side the view should be android.
From here just check each gradle build file for a + sign ahead of google play services or firebase services or any such library. This has also been explained in this answer.
After which you either change it like explained in the answer above.
like so.
implementation(project(":react-native-admob"), {
exclude group: "com.google.android.gms"
})
implementation "com.google.android.gms:play-services-ads:16.0.0"
Or you provide a variable if the library is using one or as a last resort change it there itself.
The reason I put it here is so that any newbie who is sick of this error which randomly appeared out of nowhere all of a sudden can solve it effectively and not...die. lol.
I had the same problem, just upgrade react-native-device-info and run the following command
npm upgrade react-native-device-info#latest
react-native run-android
According to #Frank's answer the library used services-gcm:+ as a dependency, and the latest gcm version caused this problem.
And I had used :react-native-admob in my project. So I just change the following lines in android/app/build.gradle
From:
implementation project(':react-native-admob')
TO :
implementation(project(":react-native-admob"), {
exclude group: "com.google.android.gms"
})
implementation "com.google.android.gms:play-services-ads:16.0.0"
If you are not using react-native-device-info, but have the same error, its probably another library in your project.
Use this to find the library in question:
cd your-react-native-project/android
./gradlew app:dependencies > deps.txt
Then inspect the deps.txt file for keyword "androidx". Then you can quickly find which native module is using it.
In my case it was react-native-camera, for which solution above was good but not enough so I had to add this to local.properties:
firebaseVersion=17.6.0
googlePlayServicesVersion=16.1.0
googlePlayServicesVisionVersion=16.2.0
EDIT:
After these fixes, running ./gradlew app:dependencies > deps.txt and searching for "androidx" returned no results - this is what we are looking for.
After running clean on the project, build worked.
Upgrading react-native-device-info to version 2.1.2 Fix my problem
Google play services breaking changes. See Release Notes.
The simple way to resolve this issue is just changing the version of Google play services.
Change all com.google.android.gms:play-services-* dependencies to version 16

Angularjs failed to instantiate module thitch ’angular-file-saver’

How to right add angular-file-saver in AngularJS project?
I trying to implement: angular-file-saver (FileSaver.js version for Angularjs) But it's not working.
1) installing filesaver file upload via bower with the command:
bower install angular-file-saver --save
2) I am trying to addition FileSaver.js module in app.js , but in browser console after starting have error:
window.mmvvtApp = angular.module('mmvvt', ['ngBootstrap', 'ngFileSaver',...
Failed to instantiate module mmvvt due to:
Error: [$injector:modulerr] http://errors.angularjs.org/1.2.26/$injector/modulerr?p0=...)
If i remove the 'ngFileSaver' from function then I am not facing the issue but when I put it in the function legislator and try to call it I get the issue.
May be non compatible versions: AngularJS#1.2.26 and angular-file-saver#1.1.3 don’t work together ?
Can someone help me please?
Thank you.
Earned after include in file "WEB-INF/jsp/main.jsp" next code:
<script src="bower_components/angular-file-saver/dist/angular-file-saver.bundle.js"></script>
AngularJS#1.2.26 and angular-file-saver#1.1.3 work together correctly.

Ember dependencies "Uncaught TypeError: $(...).fitText is not a function"

I'm attempting to use a jQuery plugin (in this case 'fitText') in an Ember project.
In the ember-cli-build.js (that replaced the Brocofile recently...) - I import the dependency (which I have already installed with bower).
/* global require, module */
var EmberApp = require('ember-cli/lib/broccoli/ember-app');
module.exports = function(defaults) {
var app = new EmberApp(defaults, {
// Add options here
});
app.import('bower_components/fittext/fittext.js');
return app.toTree();
};
In my console, I can type in 'fitText' and I DO get the object back. So, it's global now, and I should be able to use it anywhere. BUT "Uncaught TypeError: $(...).fitText is not a function"
#Tom Netzband pointed out that the bower version of fitText was the one that #adacio maintains and is vanilla JS. I've since switched it out for a app.import('vendor/jquery.fittext.js'); (the JS is really only 20 lines or so)
Previously I needed to import it in the controller or route where I want to use it - but the docs don't reference that anymore. In the docs with moment.js as the example, it seems to become a global.
I've put it in the ready hook in app.js - next to similar jQuery things that work fine... but no luck. In this case I only want to affect a few words on the index.hbs / route
UPDATE
This has really just become another question now. I thought it was still the same problem but it's not. So awarding answer and asking a new one. Thanks.
It looks like bower install fittext doesn't install the jQuery plugin version of fitText, it only installs the plain js version of it.
If you look at your bower_components/fittext/fittext.js file, you'll see jQuery isn't passed in or used, and the example from the example.html file shows usage as being:
fitText(document.getElementById('fittext'), 1.2)
So if you want the jQuery version you might have to download it straight from github and throw it in your vendor folder and include it outside of bower.
UPDATE
Looks like the version registered with bower is a forked version from the jQuery version where jQuery has been removed: https://github.com/adactio/FitText.js
There is in fact a Bower version of the jQuery version of the library.
bower install FitText.js --save
I think Dave Rupert has a jQuery version in his crates as well.
$ bower install jquery-fittext --save

Categories

Resources