I was trying to deploy a Angular 2 CLI App to a SharePoint 2013 site.
When I embed the app via a Content Editor Webpart, the app seems to work for.
Looking at the console reveals the following exception:
zone.js:158 Uncaught Error: Sys.ParameterCountException: Parameter count mismatch.(…)
Error$create # ScriptResource.axd?d=vGEzwRDnzucQkv59macWaabQYp5RLWFMwrgR1osi9VE8xnWRibgXoL_U0e3xLpsQRNiQ4MJkoONvpt…:237
Error$parameterCount # ScriptResource.axd?d=vGEzwRDnzucQkv59macWaabQYp5RLWFMwrgR1osi9VE8xnWRibgXoL_U0e3xLpsQRNiQ4MJkoONvpt…:413
Function$_validateParameterCount # ScriptResource.axd?d=vGEzwRDnzucQkv59macWaabQYp5RLWFMwrgR1osi9VE8xnWRibgXoL_U0e3xLpsQRNiQ4MJkoONvpt…:118
Function$_validateParams # ScriptResource.axd?d=vGEzwRDnzucQkv59macWaabQYp5RLWFMwrgR1osi9VE8xnWRibgXoL_U0e3xLpsQRNiQ4MJkoONvpt…:70
String$startsWith # ScriptResource.axd?d=vGEzwRDnzucQkv59macWaabQYp5RLWFMwrgR1osi9VE8xnWRibgXoL_U0e3xLpsQRNiQ4MJkoONvpt…:491
startsWith # es6.string.starts-with.js:15Sys$UI$DomEvent # ScriptResource.axd?d=vGEzwRDnzucQkv59macWaabQYp5RLWFMwrgR1osi9VE8xnWRibgXoL_U0e3xLpsQRNiQ4MJkoONvpt…:3986
browserHandler # ScriptResource.axd?d=vGEzwRDnzucQkv59macWaabQYp5RLWFMwrgR1osi9VE8xnWRibgXoL_U0e3xLpsQRNiQ4MJkoONvpt…:4052
ZoneDelegate.invokeTask # zone.js:265Zone.runTask # zone.js:154ZoneTask.invoke # zone.js:335
Where I got so far on my own is, this error is cased by SharePoints AJAX library and the ES6 shims. More accurate the string's startsWith function.
I can't remember having any issues when using angular 2 RC with the systemJS module loader. Even though I used the ES6 shims as well.
I also found out, I used the ES6-Shim directly and the angular cli uses the core-js package from NPM.
Currently I am stuck, so hoping anyone has any input on this matter.
Thanks.
I got a little further. It actually works now. I can't say it works all the way but I got no error so far.
I did remove the following line from the "polyfills.ts":
import 'core-js/es6/string';
This removes the string startsWith function causing the error. Keep in mind this only works if you include the Microsoft Ajax library, so the function is available in general.
If anyone has a better solution I would appreciate it :)
Thanks
I had the same issue in a Sharepoint feature, what worked was adding other and es6 shims before any other js packages are referenced in my master page.
My solution references ended up as:
-node_modules/core-js/client/shim.min.js
-node_modules/es6-shim/es6-shim.min.js
Hope this helps!
Related
I am working on a NextJs project. In it, I have found this piece of code inside next.config.js:
const withTM = require('next-transpile-modules')([
'some package',
'some package',
'emittery',
'#next/react-dev-overlay'
]);
I was wondering what is the purpose of this #next/react-dev-overlay and was not able to find anything online. The only thing was this unanswered question in the nextjs github issues. When I remove it, it seems that the project is working as expected. My question is what is the purpose of this #next/react-dev-overlay package and should I remove it?
The #next/react-dev-overlay package is a development-only overlay for React apps. It's used internally by Next.js to display the error messages you see in development.
This is what the error overlay looks like when a client-side error occurs in a Next.js app:
As to why that package was included in next.config.js, I can only guess that it's being used directly in that app, and needs to be transpiled to be used. Most of the times you wouldn't need to install it or use it directly.
I setup my rtl configuration step by step in v5mui. Using:
emotion as styled-engine
stylis v4
stylis-plugin-rtl v2
Every thing is OK but when using some complicated component my app appearance crashes.
There are a warning in terminal that I think will be the answer...
but I don't understand it.
WARNING in ./node_modules/stylis-plugin-rtl/dist/stylis-rtl.js
Module Warning (from ./node_modules/source-map-loader/dist/cjs.js):
Failed to parse source map from '/home/hamid/Desktop/zahra/node_modules/stylis-plugin-rtl/src/stylis-rtl.ts' file: Error: ENOENT: no such file or directory, open '/home/hamid/Desktop/zahra/node_modules/stylis-plugin-rtl/src/stylis-rtl.ts'
# ./src/index.js 8:0-42 15:18-27
It was better to say which version did you use? for instance I used version 2.1.0 anyway, I have the same problem as you said with v2.1.1 and I should use this version v2.0.2 instead.
npm i stylis-plugin-rtl#2.0.2
I hope it can help you.
Best Wishes,
Parham
I have been scratching my head for last one day on this. I am using Ngx-Toastr package in my angular application. Below are the points which I think help you understand the problem.
In dev server (ng serve) I didn't get any error there was no Nullinjector problem, then I make a production build using the following command (ng build). Until this point everything works fine. Now I need to optimize the bundle size so I ran this (ng build --prod). Build was successful no error Now it's time to serve the code (I am using Node server to serve this). Here the problem starts -
First it's asking for
'NullInjectorError: No provider for ToastrService'
which is coming from the Ngx-Toastr Package it self and It makes sense so I add that service to the appmodules and also in other Lazy loaded modules in the providers array. So after this the error has gone . But next is what I want to talk about -
Next it is asking for 'NullInjectorError: No provider for Overlay!' So I though there must be this service from the package which needs to be added in the providers array. So I tried to import it from the package it self and to add it in the providers array like below:
import { Overlay } from 'ngx-toastr/overlay/overlay';;
doing so got the below error
Module not found: Error: Can't resolve 'ngx-toastr/overlay/overlay'
Next I tried searching for this problem and found some stackoverflow solutions which suggest to add the following line:
import {OverlayModule} from '#angular/cdk/overlay';
I added this module in the imports array of every modules. Nothing got changed.
Now I have no clue what to import and where to import. And I am also not sure whether I am going right or not or where should I start looking into it. I also doubt that this error is coming from that package or what!! cause It should work without implicitly importing those services.
I run the following command to get the error ahead of production build:
ng serve --prod --optimization=false
Please also mention how to debug the following error, sometime after production build we get error like this which is undoubtly makes no sense:
ERROR Error: "StaticInjectorError[t -> t]:
StaticInjectorError(Platform: core)[t -> t]:
NullInjectorError: No provider for t!"
I hope my explanation makes some sense to you. Thanks for your time and sorry for this long question.
Lastly FYI : I have already removed node-modules and re-installed it.
Make sure you're using a version of ngx-toastr compatible with your version of angular and typescript. https://github.com/scttcper/ngx-toastr#dependencies
ngx-toastr v13 requires angular >= 10
I'm working on adding flow to a React.js app. I've used flow-typed to add several packages, which seems to be working.
This issue is that I'm using the Material-UI beta. They don't have a repo in flow-typed, but they do provide Component.js.flow files.
However, I'm getting this error:
Error: src/NotFound/NotFound.js:6
6: import Button from 'material-ui/Button'
^^^^^^^^^^^^^^^^^^^^ material-ui/Button. Required module not found
Error: src/NotFound/NotFound.js:8
8: import { withStyles } from 'material-ui/styles'
^^^^^^^^^^^^^^^^^^^^ material-ui/styles. Required module not found
My .flowconfig:
[ignore]
<PROJECT_ROOT>/node_modules/.*
<PROJECT_ROOT>/build/.*
<PROJECT_ROOT>/scripts/.*
<PROJECT_ROOT>/coverage/.*
<PROJECT_ROOT>/config/.*
.*\.test\.js
[include]
[libs]
<PROJECT_ROOT>/flow-typed/.*
[lints]
[options]
emoji=true
I've tried several solutions in support forums, but I'm still not understanding how to wire this up.
Important package versions:
react#15.5.4
material-ui#1.0.0-beta.8
flow-bin#0.54.0
Flow doesn't think material-ui exists because you're explicitly ignoring all files within node_modules in your .flowconfig. Remove the first line under [ignore] (<PROJECT_ROOT>/node_modules/.*) and you should be good to go.
Note that some other libraries may cause flow issues. You should just ignore those selectively, rather than blanket ignore all 3rd party libs.
I'm running into some issues with famous-angular when minified.
A couple of the PRs I submitted yesterday were attempts to fix this, but these don't appear to have resolved the issue.
When built without minfication, everything works as expected.
When built with minification, but removing the dependency on 'famous.angular' from my app module,
the app degrades gracefully to angular only, so the layout is borked, but the underlying angular app works as expected, no errors.
When built with minification, and the app module depends on 'famous.angular',
the app does not load at all, with the following error:
Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
Error: [$injector:modulerr] Failed to instantiate module famous.angular due to:
Error: [$injector:unpr] Unknown provider: t
http://errors.angularjs.org/1.2.23/$injector/u...<omitted>...2)
By employing this method,
I was able to determine which function was not getting minified correctly,
and tripping up Angular'S dependency injection:
function LocationHashbangInHtml5Url(appBase, hashPrefix) { /* ... */ }
This is in the core angular file - angular.js,
and it does indeed minify correctly in other instances.
So I am not sure why when I include 'famous.angular' in my app module,
this introduces the error.
Anyone know whaty is amiss here?
Demo of problem:
git clone git#github.com:bguiz/browserify-gulp-starter.git
cd browserify-gulp-starter
npm install famous
bower install --save angular angular-route famous-angular
# edit gulpoptions.js
# appName: 'app',
# appFolder: './src-famousangular/app/',
gulp serve-dist
I submitted these two PR's to famous-angular previously, thinking that I had caught all of the $inject scenarios:
https://github.com/Famous/famous-angular/pull/191
https://github.com/Famous/famous-angular/pull/190
Turns out that there was a third one that I had missed, and have now submitted a patch for:
https://github.com/Famous/famous-angular/pull/195
In my question above, I said function LocationHashbangInHtml5Url(appBase, hashPrefix) { /* ... */ } in angular/angular.js was the function that was not minifying correctly.
This was incorrect, and the culprit was in fact a provider in famous-angular/src/scripts/directives/fa-input.js.
For the curious, here is the process that I used to figure the above out.
As an added bonus, I happen to have discovered an additional technique to use when debugging dependency injection errors in minified AngularJs apps.
It turns out that the technique that I linked to above ( https://stackoverflow.com/a/25126490/194982 ) does not always work correctly.
What did work in the end, was to traverse up the execution stack, until we get to the invoke() function, as described in that technique. Then, instead of inspecting only fn, look in the Scope Variables tab in the the developer tools, and inspect every scope member which is a function.
This casts a wider net, and results in more things which need to be inspected;
but was necessary in this case, and I suspect might apply in others.