node-sqlite3
node-sqlite3 copied to clipboard
Failed to integrate with React's create-react-app
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
- Create react app via:
npm init react-app my-app - Import sqlite3 via:
npm install sqlite3 - 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:");
- 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
I receive the same bug
const db = new sqlite3.Database(":memory:"); only valid inside getStaticProps, getServerSideProps or getStaticPaths