How to compile Node.js with figlet module from pkg? - node.js

After compiling via pkg and running the .exe, I got the error:
(node:17672) UnhandledPromiseRejectionWarning: Error: File 'C:\**\mytestapp\node_modules\figlet\fonts\Ghost.flf' was not included into executable at compilation stage. Please recompile adding it as asset or script.
my index.js and package.json: https://pastebin.com/vL4nZcZW
I tried to add the entire figlet module to the asset, reinstall it and pkg, but this did not work. I tried to compile with only one require. What am I doing wrong?

Related

How can I avoid rebuilding dependencies when `cargo install` fails due to a system configuration issue?

I'm trying to cargo install a project with many dependencies. One of the later dependencies fails to build due to some system configuration issue:
cargo install diesel_cli
... many dependencies here...
Compiling diesel_cli v1.4.1
error: linking with `cc` failed: exit code: 1
|
= note: ...large output removed...
= note: ld: library not found for -lmysqlclient
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Once I think I've solved the system configuration issue, I need to re-run cargo install, wait a while for the first set of dependencies to build, then see if I get past the failure.
How can I avoid rebuilding all of those dependencies?
The error message contains the directory containing the failed build artifacts:
error: failed to compile `diesel_cli v1.4.1`, intermediate artifacts can be found at `/var/folders/_b/d4_bd15x7s5g99cjvyhpw26w0000gp/T/cargo-installDQOdPD`
You can pass that directory via the --target-dir option (or setting the CARGO_TARGET_DIR environment variable) to use it again, avoiding rebuilding the dependencies:
cargo install diesel_cli --target-dir=/var/folders/_b/d4_bd15x7s5g99cjvyhpw26w0000gp/T/cargo-installDQOdPD

Package Node-Red using zeit/pkg

I am having some issues using zeit/pkg on my node-red project. Here are the steps to replicate the issue:
git clone https://github.com/node-red/node-red.git
cd node-red
npm install
npm run build
After build command I added the following to my package.json file:
"pkg": {
"assets": [
"./red/**/*"
],
"scripts": [
"./red/**/*.js"
]
}
Run the command pkg .
After running pkg . I get the following errors:
C:\xampp\htdocs\node-red>pkg .
> pkg#4.3.4
> Targets not specified. Assuming:
node8-linux-x64, node8-macos-x64, node8-win-x64
> Warning Cannot resolve 'path.join(__dirname, '..', '..', 'package.json')'
C:\xampp\htdocs\node-red\red\runtime\index.js
Dynamic require may fail at run time, because the requested file
is unknown at compilation time and not included into executable.
Use a string literal as an argument for 'require', or leave it
as is and specify the resolved file name in 'scripts' option.
> Warning Cannot resolve ''./' + aSettings.storageModule'
C:\xampp\htdocs\node-red\red\runtime\storage\index.js
Dynamic require may fail at run time, because the requested file
is unknown at compilation time and not included into executable.
Use a string literal as an argument for 'require', or leave it
as is and specify the resolved file name in 'scripts' option.
> Warning Cannot resolve 'relPath'
C:\xampp\htdocs\node-red\red\runtime\nodes\registry\loader.js
Dynamic require may fail at run time, because the requested file
is unknown at compilation time and not included into executable.
Use a string literal as an argument for 'require', or leave it
as is and specify the resolved file name in 'scripts' option.
Running the exe after the pkg command gives me this error:
Node-RED has not been built. See README.md for details
Any help would be greatly appreciated. It seems like a simple path issue but I can't seem to get it working.

How can I use require_relative when compiling with Opal and subsequently running in Node?

I am totally new to Opal. I am just testing out how to use it by writing simple Ruby code in a local file, compiling it using opal -c test.rb > test.js, and then executing the resultant js file using node test.js. This is working fine when all of the code that I want is in test.rb. If, however, when test.rb has for the first line, require_relative 'other_file' and other_file.rb exists in the same directory with test.rb, then it fails when executed with node. I get an error message that begins like this:
/Users/huliax/projects/scratch/opaltest/test.js:5022
throw exception;
^
LoadError: can't find file: "other_file" in:
- /Users/huliax/.rvm/gems/ruby-2.5.0#car/gems/opal-0.11.0/opal
- /Users/huliax/.rvm/gems/ruby-2.5.0#car/gems/opal-0.11.0/stdlib
- /Users/huliax/.rvm/gems/ruby-2.5.0#car/gems/opal-0.11.0/lib
- /Users/huliax/.rvm/gems/ruby-2.5.0#car/gems/ast-2.3.0/lib
- /Users/huliax/.rvm/gems/ruby-2.5.0#car/gems/ast-2.3.0/lib
- /Users/huliax/.rvm/gems/ruby-2.5.0#car/gems/parser-2.3.3.1/lib
This suggests that to me that I should have no problem with require_relative. I am not getting any compile time errors. I have also tried compiling other_file.rb to js independently but that hasn't helped. I can only assume that I am misunderstanding things. What do I need to do in order to get this to work?
Ultimately, my goal is to try and use Opal to compile an entire ruby library/gem (which consists of quite a few files) to JavaScript.
Please use a relative path with require relative and include the extension, e.g.:
require_relative "./other_file.rb"
And then when compiling be sure to include the current dir or a common parent dir between the two files in the include paths, e.g.:
opal -I. test.rb -c > test.js
(tested on opal v0.11.0)

Haskell compile: the interface to load is a member of the hidden package (which is itself)

I hit this when compiling taffybar module. It is very strange that actually claim that I need load this hidden module, which is itself. Error msgs are below:
[~/Public/taffybar]-[myMaster↓]── - rm -rf ~/.cache/taffybar && taffybar
Configuration '/home/jethros/.config/taffybar/taffybar.hs' changed.
Recompiling.
Error occurred while loading configuration file.
Error:
/home/jethros/.config/taffybar/taffybar.hs:26:1: error:
Failed to load interface for ‘System.Taffybar.ToggleMonitor’
It is a member of the hidden package ‘taffybar-0.4.6’.
Use -v to see a list of the files searched for.

Compilation error on file lib/phoenix_ecto/html.ex

While compiling a project which use elixir with phoenix web framework, the following compilation error occurs:
==> phoenix_ecto
Compiled lib/phoenix_ecto.ex
Compiled lib/phoenix_ecto/plug.ex
Compiled lib/phoenix_ecto/ison.ex
==> Compilation error on file lib/phoenix_ecto/html.ex ==
** (CompileError) ib/phoenix_ecto/html.ex:7: unknown key :impl for struct Phoenix.HTML.Form
(elixir) src/e ixir_map.erl:175: :elixir_map.--assert_struct_keys/5-1c$"011-0--/5
(elixir) src/e ixir_map.erl:48: :elixir_map.translate_struct/4
(elixir) src/e ixir_clauses.erl:36: :elixir_clauses.clause/7
(elixir) src/e ixir_def.erl:178: :elixir_def.translate_clause/7
(elixir) src/e ixir_def.erl:167: :elixir_def.translate_definition/8
[31m[1mcould not compile dependency phoenix_ecto, mix compile failed. You can recompile this dependency with 'mix deps.compile phoenix_ecto' or update it with 'mix deps.update phoenix_ecto'
How can I get my project to compile correctly?
You need to update both phoenix_ecto and phoenix_html. Try this:
mix deps.clean phoenix_ecto phoenix_html
mix deps.update phoenix_ecto phoenix_html
And you should hopefully be good to go!
I forget to install and compile my application's source code and dependencies with mix do deps.get, compile. I just only install and compile under phoenix directory. Then error emitted like above. After installed and compile under my application. It do well with no error.
As clearly mentioned in the error message, try:
mix deps.compile phoenix_ecto

Resources