Module not found: Error: Can’t resolve ‘fs’ - ionic-framework

Below are the two error (image) I’m facing
I’m using Ionic 4.
everything works but as soon I start calling WooCommerce API and use it in constructor I get the below two errors.
I have imported Woocommerce API, but when I initialize it in constructr it shows both of this error.

It looks like you are using this package which has an obsolete warning:
2019-07-29: This client is obsolete and will no longer receive updates, a new JavaScript library is available under the name of #woocommerce/woocommerce-rest-api.
However, that's a node.js package. It's failing because fs stands for filesystem and that doesn't exist in the browser.
Node.js is for local development, not for browser packages, which is what Ionic 4 is built with.
However, if you really want to use it then this guide will show you how to wrap it up using browserify:
Transforming a Node.js Module to A Browser Library
The solution is to use Browserify to bundle the module with all its dependencies inside one JavaScript file so we will not need any external Node.js dependencies which are not available inside the Cordova webview (a headless browser) used by Ionic 4.
https://www.techiediaries.com/woocommerce-ionic-2/
I don't know how far you'll get as it's for Ionic 2 but I'm just showing you this to demonstrate that node.js packages are not for Ionic.
Update
Based on your comments you say you are having problems with global not being defined.
Searching Google this seems to be a solved issue, try:
I think for now the best option would be to include
(window as any).global = window;
In your polyfills.ts file, as mentioned here:
angular/angular-cli#9827 (comment)

You have to go to folder \node_modules\#angular-devkit\build-angular\src\angular-cli-files\models\webpack-configs\browser.js and replace node: false, by node: { crypto: true, stream: true, fs: "empty", net: "empty", tls: "empty" },
It's working for me.

Related

Flutter IOS Duplicate plugin key: SocialSharePlugin

I am using two different share plugins in my flutter project. One plugin social_share_plugin and other is social_share . Both are used to share content on social media. Due to limitation of one plugin i have to use both. But i am getting 'Duplicate plugin key: SocialSharePlugin'error when i run the project on IOS device. it is working fine on android device.
var s = await SocialSharePlugin.shareToFeedFacebookLink(
quote: 'Meeting',
url: shareLink,
);
and other plugin is used like
await SocialShare.shareTwitter(
shareText,
hashtags: ["meetup"],
url: shareLink,
trailingText: '#meeting',
);
The issue is social_share uses the same class name as social_share_plugin (they both have SocialSharePlugin). To resolve this, I forked the social_share package and changed every instance of SocialSharePlugin to SocialShare, including the file names.
Here's my forked repo if you would like to use or view: https://github.com/kaarens93/social_share
(I have a lot of 'unresolved reference' errors that I'm still in the process of fixing but unless you want to build the package, you shouldn't run into any issues implementing into your project)
I ended up remove SocialShare completely from the project, and use flutter_share_me and SocialSharePlugin. I found Social_Share_plugin is the only one that works with Ins (and Facebook). None of the other packages worked in this aspect. However, with version 0.4 of SocialSharePlugin you need add Facebook api token to your info.plist file since the FBSDK used by SocialSharePlugin requires this token since version 13+. This change was not documented by 0.4 SocialSharePlugin.

Writing a custom panel plugin for grafana

So I need to write a custom grafana plugin, that works like a funnel. I decided to try and integrate this funnel. Note that it is supposed to get the data from a mysql Server and use it just as a table and not as time series.
So far I read the grafana documentation and then watched this video. In the video a dataFormat is declared in the plugin.json file, however when I checked other working Plugins I didn't see that part written in the plugin.json. The GitHub repos in the video are also gone. I stumbled upon this one though, so then I copied it in the data/plugin directory. I restarted the Server and it was detected but when I tried making a new Panel I got an error saying that it could not be found. I was planning on starting with this example and then working my way towards integrating the funnel part but I can't seem to get it working. Any ideas where to start?
I have reproduced your problem with the same actions and got same error:
Panel plugin not found: myorgid-simple-panel
Just a guess: there is a dependency section in plugin.json file
"dependencies": {
"grafanaVersion": "6.3.x",
"plugins": []
}
My Grafana version is v6.2.5. Isn't this plugin template for future Grafana release (master or developement version)?
I had the same problem with simple-react-panel. To solve it, I ran in the simple-react-panel-master directory :
npm i #grafana/toolkit
npm i #grafana/ui
yarn build
and after I restart grafana service

setMyLocationButtonEnabled instance member not found in ionic-native Google Maps

I'm having an issue with the instance member of Google Maps native plugin for Ionic framework (latest version - 2.0).
The instance member is setMyLocationButtonEnabled(enabled).
The map has been displayed correctly, as I've configured it with API keys and added the plugin module to NgModule in the app.module.ts file.
Yet I'm not 100% sure I added the plugin correctly, I've done it this way:
import { GoogleMaps } from '#ionic-native/google-maps'
(...)
#NgModule({...
providers:[
GoogleMaps,
(...)
And also, I've checked the npm list and it shows the following regarding the google maps packages:
I've tried installing this package, but when I copy the link with the last bit "#2.6.0" it says it can't find the package. It works without that, and I installed it but it didn't change anything.
Anyone knows what should I do?
Thanks in advance!
EDIT: Found that this method is not yet implemented (or launched), when opening this issue.
Also, it has been updated by one side (ionic-native team) as seen in this PR: #2320, but I think npm package has not been updated yet.

Using coffeescript with basic Yeoman project.

I've used Yeoman to make a quick project skeleton using the yo webapp generator command. In the resulting Gruntfile I see that it's setup to compile CoffeeScript but it seems like its just sticking compiled files in a tmp folder.
coffee: {
dist: {
files: {
'.tmp/scripts/coffee.js': '<%= yeoman.app %>/scripts/*.coffee'
}
},
},
How do these get included in the project during development. I'm not using RequireJS.
The yeoman docs are unclear on how to use coffeescript. They only mention that it gets automatically compiled.
Using yeomen 1.0.0-rc1.4. I use:
$ yo angular --coffee
The resulting project has controller and app scripts in CoffeeScript.
grunt configuration file remains in js (what is not really a problem).
Running
$ grunt test
runs tests and all seems fine.
$ grunt server
is also doing what one expects (build the app, test it, starts server, opens the app in web browser and starts watching for changes, so if I change a coffee script file, it is quickly reflected in the web broser.
Documentation also states, one can use yo to add particular pieces like
angular:controller
angular:directive
angular:filter
angular:route
angular:service
angular:decorator
angular:view
each can be called with a --coffee switch and get the script in CoffeeScript, e.g.:
yo angular:controller user --coffee
I just found an issue in the github repo referencing this problem. https://github.com/yeoman/generator-webapp/issues/12
It offers a temporary solution: https://github.com/yeoman/generator-webapp/issues/12#issuecomment-13731929

How can I fix this Android SDK build problem in Eclipse?

I am using Eclipse for Android dev and everything was going fine until I tried to incorporate the facebook SDK. Now when I tried to back it out, there appears to be an artifact left behind that Eclipse tries to link the FB library?!?
[2010-11-17 18:50:22 - Library Project] Unable to set linked path var '_android_com.facebook.android' for library /Users/mobibob/Projects/workspace/facebook-android-sdk/facebook: Path variable name cannot contain character: ..
Any clue where this command / reference is in the build configuration? I have scoured it as best that I can, but I still get the same error.
Problem solved ... as it turns out, it was not so much the Facebook SDK but something that I did in the process of configuring the library reference. I am not entirely certain of how I misconfigured, but I was tweaking the various "path" settings such that, once when the automatic build tried to build my project, an import for android.R was added to my source module. This superseded com.myproject.R and would not resolve the values for resource references.
There were other problems with path order and setting that I modified during the troubleshooting that made it worse. Recreating the project without Facebook was the first step to discovery and fixing.
Either way, the lesson I learned is that the build error messages can misdirect one to the configuration when the problem is in the source code.