Node-canvas was built without jpeg support (M1 Max, Apple silicon) - homebrew

having issues with node-canvas on the M1 Max apple silicon machine.
This problem doesn't acquire un intel based machines.
Throwing error: node-canvas was built without JPEG support.
Also, necessary packages are installed: arch -arm64 brew install pkg-config cairo pango libpng jpeg giflib librsvg
Environment:
Node: v16.15.0
NPM: 8.11.0
Homebrew: 3.4.11
NVM: 0.39.1
Operating system: macOS v12.4
––Terminal:
...node_modules/canvas/lib/image.js:91 SetSource.call(img, src);
Error: node-canvas was built without JPEG support
at setSource (/Users/USERNAME/PROJECT_NAME/node_modules/canvas/lib/image.js:91:13)
––package.json
...
"devDependencies": {
"nodemon": "^2.0.16",
"npm-check-updates": "^13.1.1"
},
...
"dependencies": {
"#azure/cognitiveservices-computervision": "^8.2.0",
"#azure/ms-rest-azure-js": "^2.1.0",
"color-convert": "^2.0.1",
"color-thief-node": "^1.0.4",
"compression": "^1.7.4",
"cors": "^2.8.5",
"dotenv": "^16.0.1",
"express": "^4.18.1",
"express-validator": "^6.14.1",
"helmet": "^5.1.0",
"http-errors": "^2.0.0",
"mongoose": "^6.3.5",
"morgan": "^1.10.0",
"nearest-color": "^0.4.4",
"node-fetch": "^2.6.1"
},
...
––.zshrc:
local brew_path="/opt/homebrew/bin"
local brew_opt_path="/opt/homebrew/opt"
local nvm_path="$HOME/.nvm"
export PATH="${brew_path}:${PATH}"
export NVM_DIR="${nvm_path}"
[ -s "${brew_opt_path}/nvm/nvm.sh" ] && . "${brew_opt_path}/nvm/nvm.sh" # This loads nvm
[ -s "${brew_opt_path}/nvm/etc/bash_completion.d/nvm" ] && . "${brew_opt_path}/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completionexport PATH="/opt/homebrew/opt/jpeg-turbo/bin:$PATH"
# heroku autocomplete setup
HEROKU_AC_ZSH_SETUP_PATH=/Users/USERNAME/Library/Caches/heroku/autocomplete/zsh_setup && test -f $HEROKU_AC_ZSH_SETUP_PATH && source $HEROKU_AC_ZSH_SETUP_PATH;
# heroku autocomplete setup
HEROKU_AC_ZSH_SETUP_PATH=/Users/USERNAME/Library/Caches/heroku/autocomplete/zsh_setup && test -f $HEROKU_AC_ZSH_SETUP_PATH && source $HEROKU_AC_ZSH_SETUP_PATH;

Related

Not able to use wkhtmltopdf in containerized AWS lambda

I have to make a pdf out of some html pages in a containerized lambda. For this purpose I am trying to use pdfkit and wkhtmltopdf. I am not able to use it an d receiving the error as shown in picture-
Error text-
No wkhtmltopdf executable found: "./wkhtmltopdf"
If this file exists please check that this process can read it or you can pass path to it manually in method call, check README. Otherwise please install wkhtmltopdf - https://github.com/JazzCore/python-pdfkit/wiki/Installing-wkhtmltopdf
My lambda code:-
import pdfkit as pdf
def lambda_function:
config = pdf.configuration(wkhtmltopdf='./wkhtmltopdf')
pdf.from_file(
filelist_new,
output_filename,
options={
'margin-top': '0.2in',
'margin-right': '0.2in',
'margin-bottom': '0.4in',
'margin-left': '0.2in',
'orientation': 'Landscape',
'page-size': 'A4',
'encoding': 'UTF-8',
'footer-line': '',
'footer-spacing': 1,
'footer-font-name': 'Times,serif',
'footer-font-size': '10'
},
configuration=config,
)
My docker file-
FROM umihico/aws-lambda-selenium-python:latest
RUN pip install pdfkit
RUN pip install boto3
RUN pip install wkhtmltopdf --target "./"
COPY lambda_function.py ./
CMD [ "lambda_function.lambda_handler" ]
and this is when I tried to find wkhtmlpdf by running the docker container:-
Update: Issue got solved
This worked for my case.
DockerFile:
FROM umihico/aws-lambda-selenium-python:latest
RUN pip install pdfkit --target ${LAMBDA_TASK_ROOT}
RUN pip install boto3
RUN yum install -y openssl xorg-x11-fonts-75dpi xorg-x11-fonts-Type1
RUN curl "https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox-0.12.6-1.amazonlinux2.x86_64.rpm" -L -o wkhtmltox-0.12.6-1.amazonlinux2.x86_64.rpm
RUN rpm -i wkhtmltox-0.12.6-1.amazonlinux2.x86_64.rpm
COPY lambda_function.py ./
CMD [ "lambda_function.lambda_handler" ]
Lambda code:
import pdfkit as pdf
def lambda_function:
config = pdf.configuration(wkhtmltopdf='/usr/local/bin/wkhtmltopdf')
pdf.from_file(
filelist_new,
output_filename,
options={
'enable-local-file-access': '',
'margin-top': '0.2in',
'margin-right': '0.2in',
'margin-bottom': '0.4in',
'margin-left': '0.2in',
'orientation': 'Landscape',
'page-size': 'A4',
'encoding': 'UTF-8',
'footer-line': '',
'footer-spacing': 1,
'footer-font-name': 'Times,serif',
'footer-font-size': '10'
},
configuration=config,
)
Links which I referred- https://micropyramid.com/blog/how-to-create-pdf-files-in-python-using-pdfkit/ , How to install wkhtmltopdf on a linux based (shared hosting) web server

XCode 14 React Native project fails to run iOS: Command PhaseScriptExecution failed

Trying to run the react-native project but encountered the following error
N/A: version "default -> N/A" is not yet installed.
You need to run "nvm install default" to install it before using it.
Command PhaseScriptExecution failed with a nonzero exit code
Output of npx react-native info
System:
OS: macOS 12.5.1
CPU: (10) arm64 Apple M1 Max
Memory: 359.91 MB / 32.00 GB
Shell: 5.8.1 - /bin/zsh
Binaries:
Node: 16.17.0 - /usr/local/bin/node
Yarn: 1.22.18 - ~node_modules/.bin/yarn
npm: 8.19.1 - /opt/homebrew/bin/npm
Watchman: 2022.09.05.00 - /opt/homebrew/bin/watchman
Managers:
CocoaPods: 1.11.2 - /usr/local/bin/pod
SDKs:
iOS SDK:
Platforms: DriverKit 21.4, iOS 16.0, macOS 12.3, tvOS 16.0, watchOS 9.0
Android SDK: Not Found
IDEs:
Android Studio: 2021.2 AI-212.5712.43.2112.8609683
Xcode: 14.0/14A309 - /usr/bin/xcodebuild
Languages:
Java: 11.0.15 - /usr/bin/javac
npmPackages:
#react-native-community/cli: Not Found
react: 17.0.2 => 17.0.2
react-native: 0.67.4 => 0.67.4
react-native-macos: Not Found
npmGlobalPackages:
*react-native*: Not Found
I did remove nvm from ./zshrc but still got the error
was able to resolve it by commenting out
# Define NVM_DIR and source the nvm.sh setup script
[ -z "$NVM_DIR" ] && export NVM_DIR="$HOME/.nvm"
# Source nvm with '--no-use' and then `nvm use` to respect .nvmrc
# See: https://github.com/nvm-sh/nvm/issues/2053
if [[ -s "$HOME/.nvm/nvm.sh" ]]; then
# shellcheck source=/dev/null
. "$HOME/.nvm/nvm.sh" --no-use
nvm use 2> /dev/null || nvm use default
elif [[ -x "$(command -v brew)" && -s "$(brew --prefix nvm)/nvm.sh" ]]; then
# shellcheck source=/dev/null
. "$(brew --prefix nvm)/nvm.sh" --no-use
nvm use 2> /dev/null || nvm use default
fi
in node_modules/react-native/scripts/find-node.sh

Exception in GraalVM 22.2 native-image on Ubuntu 22.04

I am trying to compile a Java app into a native image using GraalVM 22.2 on my Ubuntu 22.04 workstation. I have followed the installation instructions here:
https://www.graalvm.org/22.1/docs/getting-started/linux/
GraalVM is installed and seems happy:
# /opt/graalvm/bin/java -version
openjdk version "17.0.4" 2022-07-19
OpenJDK Runtime Environment GraalVM CE 22.2.0 (build 17.0.4+8-jvmci-22.2-b06)
OpenJDK 64-Bit Server VM GraalVM CE 22.2.0 (build 17.0.4+8-jvmci-22.2-b06, mixed mode, sharing)
Here's how I'm calling native-image for my app:
/opt/graalvm/bin/native-image \
-H:ReflectionConfigurationFiles=graalvm/reflect.json \
-H:+ReportExceptionStackTraces \
--no-fallback \
--enable-url-protocols=http \
--initialize-at-build-time=org.slf4j.LoggerFactory \
--initialize-at-build-time=org.slf4j.impl.SimpleLogger \
--initialize-at-build-time=org.slf4j.impl.StaticLoggerBinder \
-jar ../app/target/app-0.9.jar
But I'm getting this exception:
Error: Collecting native-compiler info with '/usr/bin/gcc -v' failed
Error: To prevent native-toolchain checking provide command-line option -H:-CheckToolchain
com.oracle.svm.core.util.UserError$UserException: Collecting native-compiler info with '/usr/bin/gcc -v' failed
To prevent native-toolchain checking provide command-line option -H:-CheckToolchain
at org.graalvm.nativeimage.builder/com.oracle.svm.core.util.UserError.abort(UserError.java:138)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.c.codegen.CCompilerInvoker.addSkipCheckingInfo(CCompilerInvoker.java:104)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.c.codegen.CCompilerInvoker.<init>(CCompilerInvoker.java:72)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.c.codegen.CCompilerInvoker$LinuxCCompilerInvoker.<init>(CCompilerInvoker.java:212)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.c.codegen.CCompilerInvoker.create(CCompilerInvoker.java:80)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.setupNativeImage(NativeImageGenerator.java:891)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.doRun(NativeImageGenerator.java:561)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGenerator.run(NativeImageGenerator.java:521)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.buildImage(NativeImageGeneratorRunner.java:407)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.build(NativeImageGeneratorRunner.java:585)
at org.graalvm.nativeimage.builder/com.oracle.svm.hosted.NativeImageGeneratorRunner.main(NativeImageGeneratorRunner.java:128)
However, gcc is installed and is also happy:
# /usr/bin/gcc -v
Using built-in specs.
COLLECT_GCC=/usr/bin/gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/11/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none:amdgcn-amdhsa
OFFLOAD_TARGET_DEFAULT=1
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 11.2.0-19ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-11/README.Bugs --enable-languages=c,ada,c++,go,brig,d,fortran,objc,obj-c++,m2 --prefix=/usr --with-gcc-major-version-only --program-suffix=-11 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --disable-werror --enable-cet --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-offload-targets=nvptx-none=/build/gcc-11-gBFGDP/gcc-11-11.2.0/debian/tmp-nvptx/usr,amdgcn-amdhsa=/build/gcc-11-gBFGDP/gcc-11-11.2.0/debian/tmp-gcn/usr --without-cuda-driver --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.2.0 (Ubuntu 11.2.0-19ubuntu1)
It turns out that the problem was that some permissions got clobbered in the /opt/graalvm folder. Removing and re-extracting the folder fixed the problem for me.

what is the command code for 64bit windows electron js?

In Nodejs Package.json i have the below commands for 32bit Windows app:
"package-win": "electron-packager . Test -App --overwrite --asar=true --platform=win32 --arch=ia32 --prune=true --out=release-builds --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName=\"Test App\"",
but i want the same for 64bit architecture.
Just replace --arch=ia32 to --arch=x64.
"platform" stays "win32", it's all right.

Unable to install opencv On Mac OSX 10.7.3 with XCode 4.2 using MacPort

I'm trying to install opencv using MacPort. i try:
sudo port selfupdate
sudo port install opencv
and i retrieve:
---> Computing dependencies for opencv
---> Dependencies to be installed: dirac cppunit autoconf help2man p5.12-locale-gettext m4 automake libtool faac faad2 ffmpeg XviD apple-gcc42 gcc_select gmake lame libogg libsdl xorg-libXext pkgconfig glib2 xorg-libX11 xorg-bigreqsproto xorg-inputproto xorg-kbproto xorg-libXau xorg-xproto xorg-libXdmcp xorg-libxcb python27 db46 libedit python_select sqlite3 python27 xorg-libpthread-stubs xorg-xcb-proto libxml2 xorg-util-macros xorg-xcmiscproto xorg-xextproto xorg-xf86bigfontproto xorg-xtrans xorg-libXrandr xorg-randrproto xrender xorg-renderproto libtheora libvorbis libvpx yasm openjpeg jbigkit lcms2 jpeg tiff libpng schroedinger orc speex texi2html x264 jasper liboil
---> Configuring p5.12-locale-gettext
Error: Target org.macports.configure returned: configure failure: shell command failed (see log for details)
Error: Failed to install p5.12-locale-gettext
Log for p5.12-locale-gettext is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_perl_p5-locale-gettext/p5.12-locale-gettext/main.log
Error: The following dependencies were not installed: dirac cppunit autoconf help2man p5.12-locale-gettext m4 automake libtool faac faad2 ffmpeg XviD apple-gcc42 gcc_select gmake lame libogg libsdl xorg-libXext pkgconfig glib2 xorg-libX11 xorg-bigreqsproto xorg-inputproto xorg-kbproto xorg-libXau xorg-xproto xorg-libXdmcp xorg-libxcb python27 db46 libedit python_select sqlite3 python27 xorg-libpthread-stubs xorg-xcb-proto libxml2 xorg-util-macros xorg-xcmiscproto xorg-xextproto xorg-xf86bigfontproto xorg-xtrans xorg-libXrandr xorg-randrproto xrender xorg-renderproto libtheora libvorbis libvpx yasm openjpeg jbigkit lcms2 jpeg tiff libpng schroedinger orc speex texi2html x264 jasper liboil
Error: Status 1 encountered during processing.
To report a bug, see <http://guide.macports.org/#project.tickets>
what could be the error? how can i resolve it?
Error: Failed to install p5.12-locale-gettext
Read the error messages carefully, then open the log it suggests to find out what the problem really was:
Log for p5.12-locale-gettext is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_tarballs_ports_perl_p5-locale-gettext/p5.12-locale-gettext/main.log
If you still can't solve the problem, then you can always download OpenCV source code and compile it on your Mac.
you can download
http://vislab.cs.vt.edu/~vislab/wiki/images/4/44/OpenCV2.0.dmg
and copy the folder inside dmg into the framework library..

Resources