node-sqlite3 icon indicating copy to clipboard operation
node-sqlite3 copied to clipboard

Failed to integrate with React's create-react-app

Open rixment opened this issue 2 years ago • 2 comments

Issue Summary

After running npm start command the following error occurs:

Compiled with problems:X

ERROR in ./node_modules/@mapbox/node-pre-gyp/lib/util/nw-pre-gyp/index.html 1:0

Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <!doctype html>
| <html>
| <head>


ERROR in ./node_modules/@gar/promisify/index.js 5:4-19

Module not found: Error: Can't resolve 'util' in 'C:\my-app\node_modules\@gar\promisify'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
	- install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "util": false }


ERROR in ./node_modules/@mapbox/node-pre-gyp/lib/clean.js 6:15-35

Module not found: Error: Can't resolve 'fs' in 'C:\my-app\node_modules\@mapbox\node-pre-gyp\lib'


ERROR in ./node_modules/@mapbox/node-pre-gyp/lib/clean.js 6:39-61

Module not found: Error: Can't resolve 'path' in 'C:\my-app\node_modules\@mapbox\node-pre-gyp\lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
	- install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "path": false }


ERROR in ./node_modules/@mapbox/node-pre-gyp/lib/install.js 5:11-24

Module not found: Error: Can't resolve 'fs' in 'C:\my-app\node_modules\@mapbox\node-pre-gyp\lib'


ERROR in ./node_modules/@mapbox/node-pre-gyp/lib/install.js 6:13-28

Module not found: Error: Can't resolve 'path' in 'C:\my-app\node_modules\@mapbox\node-pre-gyp\lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
	- install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "path": false }


ERROR in ./node_modules/@mapbox/node-pre-gyp/lib/main.js 45:13-26

Module not found: Error: Can't resolve 'fs' in 'C:\my-app\node_modules\@mapbox\node-pre-gyp\lib'


ERROR in ./node_modules/@mapbox/node-pre-gyp/lib/main.js 108:13-26

Module not found: Error: Can't resolve 'os' in 'C:\my-app\node_modules\@mapbox\node-pre-gyp\lib'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "os": require.resolve("os-browserify/browser") }'
	- install 'os-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "os": false }

[...]

Steps to Reproduce

  1. Create react app via: npm init react-app my-app
  2. Import sqlite3 via: npm install sqlite3
  3. Add the following lines to App.js
import logo from "./logo.svg";
import "./App.css";

const sqlite3 = require("sqlite3").verbose();
const db = new sqlite3.Database(":memory:");
  1. Run environment via: npm start

Version

5.1.4

Node.js Version

19.5.0

How did you install the library?

Windows 8.1 64bit

rixment avatar Jan 28 '23 10:01 rixment

I receive the same bug

joki20 avatar Jan 31 '23 02:01 joki20

const db = new sqlite3.Database(":memory:"); only valid inside getStaticProps, getServerSideProps or getStaticPaths

arma7x avatar Mar 26 '23 11:03 arma7x