I've encountered an issue trying to use bazel as a build tool for remix. I've been able to run remix in dev mode but currently unable to get remix build to work.
I've encountered a few errors that led up to this point. I'll list the errors in the order which they occurred with my fixes (just incase any of the fixes introduces a new issue)
First error in the bazel sandbox is related to a transitive dependency of #remix-run/dev (#remix-run/dev->gunzip-maybe->browserify-zlib). Bazel failed to fetch the bazel repository #npm__browserify-zlib__0.1.4. I assumed this was a bazel issue and tried to override browserify-zlib#0.1.4 with browserify-zlib#0.2.0, which worked. Here is bazel error for reference:
ERROR: /Users/emmanuel/projects/bbbazel/WORKSPACE:89:17: fetching _npm_import rule //external:npm__browserify-zlib__0.1.4: Traceback (most recent call last):
File "/private/var/tmp/_bazel_emmanuel/f416ba8913b741927ac435783e3163e0/external/aspect_rules_js/npm/private/npm_import.bzl", line 471, column 27, in _impl
pkg_json = json.decode(rctx.read(pkg_json_path))
Error in decode: at offset 685, object has duplicate key: "main"
ERROR: /private/var/tmp/_bazel_emmanuel/f416ba8913b741927ac435783e3163e0/external/npm/BUILD.bazel:3012:6: #npm//:npm__browserify-zlib__0.1.4_source_directory depends on #npm__browserify-zlib__0.1.4//:source_directory in repository #npm__browserify-zlib__0.1.4 which failed to fetch. no such package '#npm__browserify-zlib__0.1.4//': at offset 685, object has duplicate key: "main"
Next error in the bazel sandbox is related to another transitive dependency of #remix-run/dev (#remix-run/dev->xdm->deasync). The install lifecycle hook for the deasync npm package makes a call to the node-gyp binary which doesn't exist in the sandbox and the bazel build command fails during setup. To fix this, I disabled the install lifecycle hook (I also disabled it with a pnpm install outside the sandbox and the remix build command executed perfectly) which led to the final error. Here's the error message for this error:
/Users/emmanuel/projects/bbbazel/BUILD.bazel:5:22: Running lifecycle hooks on npm package deasync#0.1.28 failed: (Exit 1): lifecycle-hooks.sh failed: error executing command (from target //:.aspect_rules_js/node_modules/deasync#0.1.28/lc) bazel-out/darwin_arm64-opt-exec-2B5CBBC6/bin/external/aspect_rules_js/npm/private/lifecycle/lifecycle-hooks.sh deasync ../../../external/npm__deasync__0.1.28/package ... (remaining 1 argument skipped)
/private/var/tmp/_bazel_emmanuel/f416ba8913b741927ac435783e3163e0/execroot/fleet/bazel-out/darwin_arm64-fastbuild/bin/external/aspect_rules_js/npm/private/lifecycle/min/node-gyp-bin/node-gyp: line 5: 1211: command not found
node-gyp not found! Please upgrade your install of npm! You need at least 1.1.5 (I think) and preferably 1.1.30.
> deasync#0.1.28 install /private/var/tmp/_bazel_emmanuel/f416ba8913b741927ac435783e3163e0/execroot/fleet/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/deasync#0.1.28/node_modules/deasync
> node ./build.js
===============================================================
Failure while running lifecycle hook for package 'deasync#0.1.28':
Script: 'install'
Command: `node ./build.js`
Stack trace:
spawn ENOENT
at ChildProcess.<anonymous> (/private/var/tmp/_bazel_emmanuel/f416ba8913b741927ac435783e3163e0/execroot/fleet/bazel-out/darwin_arm64-fastbuild/bin/external/aspect_rules_js/npm/private/lifecycle/min/index.min.js:1:91930)
at ChildProcess.emit (node:events:513:28)
at maybeClose (node:internal/child_process:1100:16)
at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
The final error suggests a bug with remix, but since it only occurs in the bazel sandbox I think it may be an issue that cuts across bazel and remix. The error returned is shown below:
The following error is a bug in Remix; please open an issue! https://github.com/remix-run/remix/issues/new
Missing output for entry point
Error
at Object.onCompileFailure (/private/var/tmp/_bazel_emmanuel/f416ba8913b741927ac435783e3163e0/sandbox/darwin-sandbox/1566/execroot/fleet/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/#remix-run+dev#1.12.0_#remix-run+serve#1.12.0/node_modules/#remix-run/dev/dist/cli/commands.js:180:13)
at Object.compile (/private/var/tmp/_bazel_emmanuel/f416ba8913b741927ac435783e3163e0/sandbox/darwin-sandbox/1566/execroot/fleet/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/#remix-run+dev#1.12.0_#remix-run+serve#1.12.0/node_modules/#remix-run/dev/dist/compiler/remixCompiler.js:34:134)
at async Object.build (/private/var/tmp/_bazel_emmanuel/f416ba8913b741927ac435783e3163e0/sandbox/darwin-sandbox/1566/execroot/fleet/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/#remix-run+dev#1.12.0_#remix-run+serve#1.12.0/node_modules/#remix-run/dev/dist/compiler/build.js:33:3)
at async Object.build (/private/var/tmp/_bazel_emmanuel/f416ba8913b741927ac435783e3163e0/sandbox/darwin-sandbox/1566/execroot/fleet/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/#remix-run+dev#1.12.0_#remix-run+serve#1.12.0/node_modules/#remix-run/dev/dist/cli/commands.js:175:3)
at async Object.run (/private/var/tmp/_bazel_emmanuel/f416ba8913b741927ac435783e3163e0/sandbox/darwin-sandbox/1566/execroot/fleet/bazel-out/darwin_arm64-fastbuild/bin/node_modules/.aspect_rules_js/#remix-run+dev#1.12.0_#remix-run+serve#1.12.0/node_modules/#remix-run/dev/dist/cli/run.js:449:7)
Building Remix app in production mode...
Target //examples/remix:build failed to build
I've tried to run it outside bazel and with pnpm (I added the override to the package.json for browserify-zlip#0.2.0, then I ran pnpm instal with --ignore-scripts flag) and it builds fine.
I'm not sure if this is a bug with remix or a bazel issue. Has anyone else experienced this? Or does anyone having a working version of remix with bazel as the build tool?
I've created a minified version of the repository in the state of the 3rd error https://github.com/noelenwenede/bbbazel. Start up instructions are in the readme file.
$ ionic cordova plugin add cordova-plugin-http
$ npm install --save #ionic-native/http
The implementation is:
constructor(private https: HTTP ) {
}
this.https.get('http://ionic.io', {}, {})
.then(data => {
this.httpData =data;
console.log(data.status);
})
.catch(error => {
console.log(error.status);
});
And I get this error:
[20:49:03] console.warn: Native: tried calling HTTP.get, but the HTTP plugin is not installed.
[20:49:03] console.warn: Install the HTTP plugin: 'ionic plugin add cordova-plugin-http'
If you do not want to modify the ionic-native plugin like suggested by #alpere or if the solution does not work you can always use the cordova plugin without ionic-native. To do so tell typescript that the http handle exists by adding the following somewhere below your imports:
declare var http;
And then use it like this:
http.get(
'https://ionic.io/',
{},
{},
response => {
console.log(response.status);
},
response => {
console.error(response.error);
},
);
Note that there is no need of this because cordova plugins are defined on a global scope. The downside of using plugins without the ionic-native wrapper is that you loose the nice type annotations, promise callbacks and in some cases you will have to trigger angular change-detection yourself.
The Ionic Native HTTP changed the cordova plugin they are using since the old one hasn't been updated for a while. During the change the reference to the plugin has't been updated so it's broken.
(See: https://github.com/silkimen/cordova-plugin-advanced-http/issues/8)
You can fix it by changing the old referenced plugin to new one:
(After the commit also updating the plugin will fix the issue)
in #ionic-native/plugins/http/index.ts:
change:
pluginRef: 'cordovaHTTP',
to:
pluginRef: 'cordova.plugin.http',
See commit:
https://github.com/ionic-team/ionic-native/commit/49ee0d85a304770a9a3bd3e04eb9609e6d565b67
It may be caused by any of these three issues:
The plugin is not installed;
You ran the code on a browser (or other limited environment); or
The platform is not ready (You called your code before the plugin was loaded).
The master branch of ionic already fixed pluginRef: 'cordova.plugin.http',
problem,
Still if the problem persists or you don't want to change the source files try these steps, it worked for me.
remove existing builds
rm -rf node_modules/ platforms/ plugins/ www/
update ionic native to latest build :
npm i --save ionic-native#latest
(please check with other plugin dependencies as well if its a problem try isolating packages via virtual environment setup - https://github.com/ekalinin/nodeenv ) :
add all your plugins required and http plugin ::
ionic cordova plugin add cordova-plugin-advanced-http
Then finally your plugins required and http plugin
npm install #ionic-native/http
Now your upon builds iOS or android should detect all the plugins
Ionic3 Cordova SSL pinning example
https://github.com/sijovijayan/SSL-pinning-with-ionic-cordova-example
In this example, you will get an idea about how implement SSL Pinning and How to Generate .cer file
try to run below command as suggested in error message to install HTTP plugin
ionic plugin add cordova-plugin-http
I would switch to Angular's HTTP instead of Cordova HTTP. Advantage: Does not require any plugin.
package.json:
"dependencies": {
...
"#angular/http": "4.1.3",
...
}
app.module.ts:
import { Http, HttpModule } from '#angular/http';
...
#NgModule({
declarations: [
MyApp,
],
imports: [
...
HttpModule,
...
]...
calling .ts-class:
import { Http } from '#angular/http';
...
constructor(... , public http: Http, ...) {
//Example: .get for a JSON and map it:
this.http.get(url).map(res => res.json()).subscribe(data => {
this.data = data;
});
}
Answer to first Comment:
As you seem to need SSL Pinning and I did not find an easy way in Angular HTTP yet, i saw that your command of adding the cordova plugin differs a little from the one from the documentation:
You wrote:
ionic cordova plugin add cordova-plugin-http
Now the command seems to be:
ionic cordova plugin add cordova-plugin-advanced-http
(https://ionicframework.com/docs/native/http/)
As you can see there, it supports your needs with methods like enableSSLPinning(enable).
If you are running the app from your pc, you might get such error.
Try using ionicdev
Ionic native plugins depend on the device features. So because of this plugins like http, contacts or camera would not work on your browser. An Example of such error is
Native: tried calling HTTP.post, but Cordova is not available. Make sure to include cordova.js or run in a device/simulator
So try to get ionic's app for developing app here https://play.google.com/store/apps/details?id=io.ionic.devapp
I had the same problem. And I managed to get rid of that error simply by declaring the Angular's HTTP module.
In app/app.modules.ts
import { HttpClientModule } from '#angular/common/http';
#NgModule({
imports: [
// import HttpClientModule after BrowserModule.
HttpClientModule,
],
})
Even if I don't use Angular's Module, this solved my problem.
Have you ever try to call plugin after the platform ready then check platform?
async checkVersion() {
const ready = !!await this.platform.ready();
if (ready && this.platform.is('cordova')) {
// try to add your code here
}
}
you have to remove code from ngoninit and add it in ionviewdidenter
ionViewDidEnter(){
//your code here
}
I have the following code in my TS file...
require("jquery-ui/ui/widgets/datepicker.js");
require("angular-ui-date/dist/date.js");
When I run the code I get the following error...
Module not found: Error: Cannot resolve module 'jquery-ui/datepicker' in //code/my-app/node_modules/angular-ui-date/dist
# ./~/angular-ui-date/dist/date.js 3:66-97
So I ran tsd install jqueryui --save and then added the following to the same file as the require...
/// <reference path="../../../typings/jqueryui/jqueryui.d.ts" />
based on src/main/typescripts but I still get the same warning when running webpack
It seems to be a issue with latest version you are using. It has nothing to do with type definition. if you open angular-ui-date/dist/date.js you will find that it is requiring
require("jquery-ui/datepicker")
which does not exist
to workaround you could change it manually to require("jquery-ui/ui/widgets/datepicker") but that's a ugly solution i think.
There is also an issue on github and there is also suggestion for workaround
Please see the isse here
I added an alias to the resolve object in the webpack configuration file.
'resolve' : {
'alias' : {
'jquery-ui/datepicker' : 'jquery-ui/ui/widgets/datepicker'
},
},
I get the following error:
Message:
Unable to find suitable version for underscore
Details:
code: ECONFLICT
picks: [object Object],[object Object],[object Object]
With the following bower file, this error I have never come across before. I cannot use the interactive shell, as this gets deployed to continuous integration. We also prefer to use Github repo links (don't ask me why) over bower packages.
{
"name": "Nightbird",
"version": "0.0.1",
"main": "src/css/style.scss",
"dependencies": {
"backbone": "git#github.com:jashkenas/backbone.git#1.1.2",
"underscore": "git#github.com:jashkenas/underscore.git#1.6.0",
"aisis-bootstrap-theme": "git#github.com:AdamKyle/Aisis-Bootstrap-Theme.git#0.5.0",
"selectize.js": "git#github.com:brianreavis/selectize.js.git#0.8",
"underscore.string": "git#github.com:epeli/underscore.string.git#v2.3.2",
"jquery-bootpag": "git#github.com:botmonster/jquery-bootpag.git#1.0.5",
"underscore.inflection": "git#github.com:jeremyruppel/underscore.inflection.git",
"moment": "git#github.com:moment/moment.git",
"bootstrap-markdown": "git#github.com:toopay/bootstrap-markdown.git#2.5.0",
"markdown-js": "git#github.com:evilstreak/markdown-js.git#v0.5.0",
"to-markdown": "git#github.com:domchristie/to-markdown.git#v0.0.2",
"font-awesome": "git#github.com:FortAwesome/Font-Awesome.git#4.2.0",
"react-bower": "git#github.com:reactjs/react-bower.git#0.11.1",
"showdown": "git#github.com:coreyti/showdown.git#0.3.1",
"pure": "git#github.com:yahoo/pure.git#0.5.0"
}
}
Any idea whats going on? Is this a bug? or just a developer being dumb?
You have a conflict between 3 different versions of underscore.
The reason for this is that underscore is required by 3 of your dependencies: Nightbird, backbone and underscore.inflection.
Using the latest version of Bower you can see the following information:
Unable to find a suitable version for underscore, please choose one:
1) underscore#1.6.0 which resolved to 1.6.0 and is required by Nightbird
2) underscore#>=1.5.0 which resolved to 1.6.0 and is required by backbone#1.1.2
3) underscore#~1.7.0 which resolved to 1.7.0 and is required by underscore.inflection#1.2.0
You can force bower to use a specific version in case of resolution by adding the following to your bower.json. In this example it will force using 1.6.0:
"resolutions": {
"underscore": "1.6.0"
}
I encountered some weird errors when running "pub install" for dart-html5-samples. The first one was:
Illegal argument(s): join(): part 0 was null, but part 1 was not.
The second one was:
Running pub install ...
Pub install failed, [1] Resolving dependencies...
Could not find package "unittest 0.0.0-r.13075" at http://pub.dartlang.org.
What's going on, and how do I fix it?
The first error is:
Illegal argument(s): join(): part 0 was null, but part 1 was not.
That's because pubspec.yaml contained:
dependencies:
htmlescape:
sdk: htmlescape
htmlescape no longer comes with the SDK. Removing the dependency fixed the problem. I simply made a copy of htmlescape.dart in my lib directory. Eventually, I won't need my own copy once the following bug is fixed:
http://code.google.com/p/dart/issues/detail?id=1657
The second error is:
Running pub install ...
Pub install failed, [1] Resolving dependencies...
Could not find package "unittest 0.0.0-r.13075" at http://pub.dartlang.org.
dart-html5-samples depends on vector_math which depends on unittest. I think they must have changed how unittest is loaded by pub. Running pub update fixed the problem.