I package my app with nw.js v0.12.3 and I'm use dns node.js module. When I started my app with 'nw .' all works fine. But when I package my app with nw-packager I have an error 'Uncaught error: No module dns'.
You need to install the dns module via npm install dns --save (not --save-dev) so it's marked as a post-development dependency ("dependencies": in your package.json file instead of "devDependencies":) and is packaged with your app.
Then you should be able to check that the dns module is packed with your code and the nwjs runtime using a tool such as 7-Zip.
nw-packager uses nw-builder under the hood so any manifest options (package.json) that are documented in nw-builder apply to nw-packager
Related
I am trying to use google-auth-library with a react app but am getting various errors which seem to indicate missing dependencies. The errors are all in a format similar to this:
Module not found: Error: Can't resolve 'buffer' in '/private/tmp/minimal-example/node_modules/buffer-equal-constant-time'
The error messages include details on how to add a polyfill for the missing dependencies, but even after going through and adding all these polyfills I am unable to use the library. The logs for the development server still show errors for missing files, and the browser console has the following error:
GET http://metadata.google.internal./computeMetadata/v1/instance net::ERR_NAME_NOT_RESOLVED
Steps to reproduce:
Install Node 16.13.2
Create a react app npx create-react-app minimal-example
Enter directory for the created project cd minimal-example
Install google-auth-library npm install google-auth-library --save
Add the following code to ./src/App.js
const {GoogleAuth} = require('google-auth-library');
Start the development server npm start
Observe errors
What am I doing wrong?
I Have the same problem with same google-auth-library package!
This is a problem with using webpack 5 on React scripts=> v5
Have three solutions to resolve:
downgrade react-scripts to version 4.0.3. on package.json file.
Overwrite the config webpack config, but, i will need install react-app-rewired to do this, because react app not have webpack.config on tree app files.
you can eject the script to root folder executing npm run eject, but caution, this action is permanent, more here: https://stackoverflow.com/a/48395890
Some people answered this problem in How to Polyfill node core modules in webpack 5
and https://github.com/facebook/create-react-app/issues/12072
I am trying to make a simple electron app built on the electron react boilerplate that queries a local instance of a Microsoft SQL server that I have. Since I want to use Windows Authentication it seems that I have to use the msnodesqlv8 package, but on install it throws a series of warnings that then lead to errors and crashes on startup.
My system environment is electron react boilerplate (which includes webpack) installed on 64-bit Windows 10, with a local running instance of a MS SQL Server 2017. I do my package management through yarn, but npm install yields the same issues. Cmd is being run as an administrator. My process versions are as follows:
chrome: "78.0.3904.130"
electron: "7.1.4"
node: "12.8.1"
v8: "7.8.279.23-electron.0"
The exact log on yarn is:
WARNING in ./node_modules/msnodesqlv8/lib/bootstrap.js 37:23-38
Critical dependency: the request of a dependency is an expression
# ./node_modules/msnodesqlv8/lib/connection.js
# ./node_modules/msnodesqlv8/lib/sql.js
# dll renderer
WARNING in ./node_modules/msnodesqlv8/lib/bootstrap.js 57:25-40
Critical dependency: the request of a dependency is an expression
# ./node_modules/msnodesqlv8/lib/connection.js
# ./node_modules/msnodesqlv8/lib/sql.js
# dll renderer
it seems to be an error in the included bootstrap library, but I have not found any way to stop it or fix it. If anyone knows how to make this driver work (or any MSSQL Windows authentication alternatives to msnodesqlv8), I would appreciate the help.
Edit
I found a tentative workaround thanks to TimelordUK/node-sqlserver-v8/pull/131, using the following steps.
install node-loader
npm install node-loader --save-dev or yarn add node-loader
add the following rule to your webpack.config.js (or webpack.config.base.js, if using electron-react-boilerplate)
{
test: /\.node$/,
use: 'node-loader'
}
install node-sql-server-v8/pull/131
If you already have the mssqlv8 package installed, remove it by running npm uninstall mssqlv8 or yarn remove mssqlv8. Then reinstall the specific pull request with npm or yarn:
npm install --save-dev TimelordUK/node-sqlserver-v8#pull/131/head
yarn add TimelordUK/node-sqlserver-v8#131/head
Copy the relevant .node binary from /node_modules/msnodesqlv8/lib/bin to the /app/bin directory.
In my case this was the sqlserverv8.node.v12.13.0.electron.v7.1.2.x64.node file. Your webpack output folder may be different, but for me it is the app folder since I am using the react boilerplate. You can find your output folder in the webpack config, ensure that it contains a bin subfolder with the proper .node binary.
Use msnodesqlv8 as usual!
I am trying to use firebase-admin npm module in a Netlify cloud function. By default netlify-lambda packages the functions with Webpack, which breaks firebase-admin as it's not compatible with Webpack.
I tried using the alternate "zip n ship" method but even that doesn't works. From the error, it seems the node_modules generated on my machine are not working correctly on the machine where the function is deployed. Here is the error:
Error: The gRPC binary module was not installed. This may be fixed by running "npm rebuild"
Original error: Cannot find module '/var/task/node_modules/grpc/src/node/extension_binary/node-v57-linux-x64-glibc/grpc_node.node'
Anyone who has made this work?
you can use Webpack to generate new package.json file into the lambda directory and install its dependencies, then run netlify-lambda as this tutorial shows firebase-admin-with-netlify-lambda
I am new to Electron (Atom-shell), and I am trying to load a NodeJS plugin into the application I am building, but I don't know how. The documentation is not clear on that.
For instance, I am trying to use sqlite3 plugin in my app, I used npm install sqlite3, and it was successfully installed. But the application throws and error when I try to call it var sqlite = require('sqlite3'). Are there any further steps I am not aware of ?
Thanks.
For pure JS (i.e. not native) modules you need the following:
Have the module listed in your package.json dependencies
Let electron know where to find the module (e.g. export NODE_PATH=/PATH/TO/node_module)
The first requirement is obvious and the second has its roots in this issue.
For native node modules (such as sqlite3) which use C++ bindings, you need to build them against electron headers to work. According to electron docs, the easiest way to do that would be:
npm install --save-dev electron-rebuild
# Every time you run npm install, run this
./node_modules/.bin/electron-rebuild
To install the npm modules correctly you should go into the folder of your electron app and install the module via npm.
npm install --save sqlite3
The flag --save is important, because npm will install the module inside your app.
Afterwards the require should work.
I have created a JS bundle file from node-xmpp using Browserify but when I load my website I get the following error in the Google Chrome Javascript console:
Uncaught Error: Cannot find module 'dns'
I tried installing the browser-request node package using npm install -g browser-request and to rebuild the JS bundle but I still get the same error.
What do I need to include/install in order to get rid of this error?
Note: I am using a debian server with the latest version of nodejs and Browserify
I found an commit that has not been added to the latest build yet that solved my problem.
https://github.com/dodo/node-xmpp/commit/a49e7be0e43885060aaf26c2772b41c618624f12
I've added a screenshot containing the changes for if the link dies: