Node.js and npm pg for postgres error - node.js

I am attempting to get the Postgesql client for node working with NPM. Using node v0.6.14 and receiving the following error:
pg#0.5.4 install /Users/matt/Sites/node_test/node_modules/pg
node-waf configure build || true
Checking for program g++ or c++ : /usr/bin/g++
...
'configure' finished successfully (0.082s)
Waf: Entering directory '/Users/matt/Sites/node_test/node_modules/pg/build'
[1/2] cxx: src/binding.cc -> build/Release/src/binding_1.o
../src/binding.cc:3:25: error: node_events.h: No such file or directory
...
Build failed: -> task failed (err #1):
{task: cxx binding.cc -> binding_1.o}
pg#0.5.4 ./node_modules/pg
└── generic-pool#1.0.6`
I have set the $NODE_PATH, and feel a bit stuck at this point, not quite knowing what is wrong. Thank you!

I was following the Heroku 'Getting Started with Node.js' article and that suggests using v0.5.4 of the pg package.
However, I am using version 0.6.x of Node and that so I was getting this same error you are.
I fixed it by changing my package.json file to specify v 0.6.15 of pg.
"dependencies": {
"pg": "0.6.15"
}

Related

VS Code error `failed to run build scripts` when using Rust-Analyzer only on one specific project

My company just switched on a new repo the Rust project I'm working on, to merge it with a Tauri project, and VS Code now gave me this error:
Failed to run build scripts
I can compile, run my project or use cargo check to see the warnings/error but Rust Analyzer is not working and it's very annoying for me to run cargo check every time i need to check my code.
This error occurs only on this repo, which contains a Rust workspace separate in two folders: one Tauri/Rust project and one basic Rust project.
Cargo.toml at the root:
[workspace]
members = [
"builder",
"studio/src-tauri"
]
Error details:
[ERROR rust_analyzer::lsp_utils] failed to run build scripts:
The following warnings were emitted during compilation:
error: failed to run custom build command for `cairo-sys-rs v0.15.1`
Caused by:
process didn't exit successfully: `/home/korocouille/Sogilis/IReflex/reflex2/target/debug/build/cairo-sys-rs-decf14405d906ced/build-script-build` (exit status: 1)
--- stdout
cargo:rerun-if-env-changed=CAIRO_NO_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_PATH_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_PATH
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_LIBDIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64-unknown-linux-gnu
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR_x86_64_unknown_linux_gnu
cargo:rerun-if-env-changed=HOST_PKG_CONFIG_SYSROOT_DIR
cargo:rerun-if-env-changed=PKG_CONFIG_SYSROOT_DIR
cargo:warning=`"pkg-config" "--libs" "--cflags" "cairo" "cairo >= 1.14"` did not exit successfully: exit status: 1
error: could not find system library 'cairo' required by the 'cairo-sys-rs' crate
--- stderr
Package cairo was not found in the pkg-config search path.
Perhaps you should add the directory containing `cairo.pc'
to the PKG_CONFIG_PATH environment variable
No package 'cairo' found
Package cairo was not found in the pkg-config search path.
Perhaps you should add the directory containing `cairo.pc'
to the PKG_CONFIG_PATH environment variable
No package 'cairo' found
I tried to uninstall and re-install Rust-Analyzer, switch to pre-release or older version, delete my target folder, run a cargo clean cmd but nothing changed, and I can't find any solution.

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

macOS & dyld: Symbol not found: _usdt_create_provider

In short, I'm unable to install #pact-foundation/pact-node on my development computer and from what I gather it seems to be loosely related to being on macOS 10.14. When I say loosely, this does not affect my other non-development computer running the same stack.
Within nvm I've tried using Node 8.14.0, 8.15.0, 9.4.0, 10.14.2, 10.15.0 and 11.6.0, in addition to system Node, which is also 11.6.0. Each version results in the same error messages, regardless of whether I'm in my team's project directory or in an otherwise empty sandbox directory.
Until a few minutes ago I was running macOS 10.14.1 and am seeing the same problems on 10.14.2. There are no updates that haven't been installed.
The package installation output is as follows.
$ npm install #pact-foundation/pact-node
> dtrace-provider#0.8.7 install /Users/andrewgould/www/sandbox/node_modules/dtrace-provider
> node-gyp rebuild || node suppress-error.js
ACTION binding_gyp_ndtp_target_build_ndtp .
TOUCH Release/obj.target/ndtp.stamp
> spawn-sync#1.0.15 postinstall /Users/andrewgould/www/sandbox/node_modules/spawn-sync
> node postinstall
> caporal#0.10.0 postinstall /Users/andrewgould/www/sandbox/node_modules/caporal
> (test -f ./node_modules/husky/bin/install.js && node ./node_modules/husky/bin/install.js) || exit 0
> #pact-foundation/pact-node#6.20.0 postinstall /Users/andrewgould/www/sandbox/node_modules/#pact-foundation/pact-node
> node postinstall.js
dyld: lazy symbol binding failed: Symbol not found: _usdt_create_provider
Referenced from: /Users/andrewgould/www/sandbox/node_modules/dtrace-provider/src/build/Release/DTraceProviderBindings.node
Expected in: flat namespace
dyld: Symbol not found: _usdt_create_provider
Referenced from: /Users/andrewgould/www/sandbox/node_modules/dtrace-provider/src/build/Release/DTraceProviderBindings.node
Expected in: flat namespace
Abort trap: 6
Has anyone seen errors like these before? Is there a solution known?
It turns out this issue was caused by binutils, which I had installed via Homebrew. Uninstalling that fixed the problem.
From the GNU binutils website, the main packages included in it are ld, the GNU linker, and as, the GNU assembler. Both tools are included with macOS, however the Homebrew versions of these tools caused the conflicts shown in the above question.

Error installing nokogiri: Failed to build gem native extension

I want to execute the following command
bundle install && rake install
but an error comes up and I try to figure out whats going on. I found that i need to install nokogiri. But when I try to install it an error comes up again. Any ideas? :/
sudo gem install nokogiri -v '1.8.5'
Building native extensions. This could take a while...
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
current directory: /var/lib/gems/2.5.0/gems/nokogiri-1.8.5/ext/nokogiri
/usr/bin/ruby2.5 -r ./siteconf20181210-12550-orku3c.rb extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
Using mini_portile version 2.3.0
checking for gzdopen() in -lz... no
zlib is missing; necessary for building libxml2
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/usr/bin/$(RUBY_BASE_NAME)2.5
--help
--clean
--use-system-libraries
--enable-static
--disable-static
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--enable-cross-build
--disable-cross-build
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/nokogiri-1.8.5/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /var/lib/gems/2.5.0/gems/nokogiri-1.8.5 for inspection.
Results logged to /var/lib/gems/2.5.0/extensions/x86_64-linux/2.5.0/nokogiri-1.8.5/gem_make.out

Add include dir for node gyp

I am deploying a node-js app to heroku that requires the npm package imagemagic-native.
I made the buildpack install libmagick++-dev and export the include path:
export INCLUDE_PATH="$BUILD_DIR/.apt/usr/include:$INCLUDE_PATH"
export CPATH="$INCLUDE_PATH"
export CPPPATH="$INCLUDE_PATH"
Upon installing the imagemagic-native package with npm install, node-gyp is invoked to compile it's binaries. However I get this error:
remote: > imagemagick-native#1.7.0 install /tmp/build_720834c3a32b65d69ae603d7c618e20f/node_modules/imagemagick-native
remote: > node-gyp rebuild
remote:
remote: make: Entering directory `/tmp/build_720834c3a32b65d69ae603d7c618e20f/node_modules/imagemagick-native/build'
remote: CXX(target) Release/obj.target/imagemagick/src/imagemagick.o
remote: In file included from ../src/imagemagick.cc:9:
remote: ../src/imagemagick.h:1:22: warning: Magick++.h: No such file or directory
This suggests that gcc doesn't see the header files for libmagick++, because $CCPATH is not available to it.
How can I make npm install add the path to the list of include_dirs that node-gyp uses?
More detail about my use case is here: Using Magick++ in a node.js application on heroku
Try:
setting the environment variable CXX=/path/to/g++ -Ipath/to/include
and then restarting the process. If you're using bash this is done by
export CXX="/path/to/g++ -Ipath/to/include"
/path/to/include being where the missing header Magick++.h is located
if that doesn't work you may manually have to set CXX to include the -I in the makefile at /tmp/build_720834c3a32b65d69ae603d7c618e20f/node_modules/imagemagick-native/build then cding into that directory and calling make.
I've spent some time trying to answer the same question. In the end, i've found the proper way to do this here. You need to set 'include_dirs' property in ~/.node-gyp/x.x.x/common.gypi.
This is how I've set the include dir on Mac OS to /opt/local/include/ (which is where all macports intalls go):
...
['OS=="mac"', {
'defines': ['_DARWIN_USE_64_BIT_INODE=1'],
'include_dirs': ['/opt/local/include'],
'xcode_settings': {
'ALWAYS_SEARCH_USER_PATHS': 'NO',
...
Though I'm not sure it's applicable for heroku environment.
You can also use the "include_dirs" option in your project binding.gyp file. Read more about available options on the format description page.
You can now do OTHER_CFLAGS='-I/usr/local/include' supposedly. See https://github.com/nickdesaulniers/node-nanomsg/pull/144

Resources