node.jsqtubuntunpmqtwebkit

Node Project failing to build due to Qt and QtWebKit configuration problems


I am trying to build a node project that has dependencies to QT and QtWebkit & QtWebKitWidgets.

Environment Information:

When I run the npm install command, the build of project fails with error below:

> company-browser-webkit@0.2.0 install /home/rando/Desktop/git/master-node/node/browser_engines/src/browsers/webkit
> node-gyp rebuild

make: Entering directory '/home/rando/Desktop/git/master-node/node/browser_engines/src/browsers/webkit/build'
  CXX(target) Release/obj.target/nodekit/native/nodekit.o
In file included from ../native/lib/webpageapiwrap.h:9,
                 from ../native/qt_v8.h:42,
                 from ../native/instancemap.cc:7,
                 from ../native/nodekit.cc:19:
../deps/webkit_static_lib/webkit_static_lib/webpageapi.h:4:10: fatal error: QWebPage: No such file or directory
    4 | #include <QWebPage>
      |          ^~~~~~~~~~
compilation terminated.
make: *** [nodekit.target.mk:159: Release/obj.target/nodekit/native/nodekit.o] Error 1
make: Leaving directory '/home/rando/Desktop/git/master-node/node/browser_engines/src/browsers/webkit/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/rando/.nvm/versions/node/v9.6.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:127:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Linux 5.8.0-44-generic
gyp ERR! command "/home/rando/.nvm/versions/node/v9.6.1/bin/node" "/home/rando/.nvm/versions/node/v9.6.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/rando/Desktop/git/master-node/node/browser_engines/src/browsers/webkit
gyp ERR! node -v v9.6.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! dexi-browser-webkit@0.2.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the dexi-browser-webkit@0.2.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/rando/.npm/_logs/2021-03-03T10_27_38_117Z-debug.log
rando@rando-dexi:~/Desktop/git/master-node/node/browser_engines/src/browsers/webkit$ npm install 

> dexi-browser-webkit@0.2.0 install /home/rando/Desktop/git/master-node/node/browser_engines/src/browsers/webkit
> node-gyp rebuild

make: Entering directory '/home/rando/Desktop/git/master-node/node/browser_engines/src/browsers/webkit/build'
  CXX(target) Release/obj.target/nodekit/native/nodekit.o
In file included from ../native/lib/webpageapiwrap.h:9,
                 from ../native/qt_v8.h:42,
                 from ../native/instancemap.cc:7,
                 from ../native/nodekit.cc:19:
../deps/webkit_static_lib/webkit_static_lib/webpageapi.h:4:10: fatal error: QWebPage: No such file or directory
    4 | #include <QWebPage>
      |          ^~~~~~~~~~
compilation terminated.
make: *** [nodekit.target.mk:159: Release/obj.target/nodekit/native/nodekit.o] Error 1
make: Leaving directory '/home/rando/Desktop/git/master-node/node/browser_engines/src/browsers/webkit/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/home/rando/.nvm/versions/node/v9.6.1/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack     at ChildProcess.emit (events.js:127:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Linux 5.8.0-44-generic
gyp ERR! command "/home/rando/.nvm/versions/node/v9.6.1/bin/node" "/home/rando/.nvm/versions/node/v9.6.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/rando/Desktop/git/master-node/node/browser_engines/src/browsers/webkit
gyp ERR! node -v v9.6.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok 
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! dexi-browser-webkit@0.2.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the dexi-browser-webkit@0.2.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:

From a searching web, I came to conclusion that this error is because the node project is dependent of company-browser-webkit@0.2.0 package does not find the QtWebKit and QtWebKitWidgets extension and fails to build.

In Qt installation folder the QtWebKit and QtWebKitWidgets are present in include folder. What should I do that these QtWebKit and QtWebKitWidgets to be recognized from package?

enter image description here


Solution

  • This problem was caused because the incorrect path for Libs and Cflags were not pointing to right installation folder.

    I solved this issue by going to the directory: ${QT_HOME}/gcc_64/lib/pkgconfig directory and modified the files (Qt5WebKit.pc, Qt5WebKitWidgets.pc)by adding the description like below:

    #Before 
    Libs: -L/home/qt/work/install/lib -lQt5WebKit
    Cflags: -I/home/qt/work/install/include/Qt5WebKit 
    
    #After 
    Libs: -L${libdir} -lQt5WebKit
    Cflags: -I${includedir}/QtWebKit  -I${includedir}
    
    #Before
    Libs: -L/home/qt/work/install/lib -lQt5WebKitWidgets
    Cflags: -I/home/qt/work/install/include/Qt5WebKitWidgets 
    
    #After
    Libs: -L${libdir} -lQt5WebKitWidgets
    Cflags: -I${includedir}/QtWebKitWidgets  -I${includedir}