From 8223cc2e0b7e9e533ce513810c5b5c4915f417df Mon Sep 17 00:00:00 2001 From: Cameron Tacklind Date: Mon, 19 Jan 2026 18:42:00 +0000 Subject: [PATCH 1/3] Fixes no build files present. Fixes #333 #335 #346 #362 #355 #363 #394 `.gitignore` was being used by npm instead of `.npmignore` causing the build dir to be ignored. See https://stackoverflow.com/questions/40528053/npm-install-and-build-of-forked-github-repo/57829251#57829251 --- .npmignore | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 .npmignore diff --git a/.npmignore b/.npmignore new file mode 100644 index 00000000..c21e3350 --- /dev/null +++ b/.npmignore @@ -0,0 +1,10 @@ +*~ +node_modules +coverage +.nyc_output +test/ +examples/ +.travis.yml +.gitignore +rollup.config.js +test.js From 0a4f802e32f2fcd8ea37857e3542e68f4400e843 Mon Sep 17 00:00:00 2001 From: Cameron Tacklind Date: Mon, 19 Jan 2026 18:42:29 +0000 Subject: [PATCH 2/3] Use `prepare` to ensure deps are always built --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6c9ab00d..599a5e63 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "pretest": "npm run lint", "test": "node --throw-deprecation test.js", "build": "rollup -c", - "prepublish": "npm run build", + "prepare": "npm run build", "browser": "node examples/clientsideserver.js" }, "bin": { From 95f73298709742d1847cdfccb85b4909bd3689eb Mon Sep 17 00:00:00 2001 From: Cameron Tacklind Date: Mon, 19 Jan 2026 18:44:05 +0000 Subject: [PATCH 3/3] Update README.md to clarify usage of precompiled bundle and module bundlers --- README.md | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 510e6b9f..3ff13f27 100644 --- a/README.md +++ b/README.md @@ -77,9 +77,10 @@ If not specified, output type is guessed from file extension.
Recognized extensions are `png`, `svg` and `txt`. ### Browser -`node-qrcode` can be used in browser through module bundlers like [Browserify](https://github.com/substack/node-browserify) and [Webpack](https://github.com/webpack/webpack) or by including the precompiled bundle present in `build/` folder. +`node-qrcode` can be used in browser through module bundlers like [Browserify](https://github.com/substack/node-browserify) and [Webpack](https://github.com/webpack/webpack). #### Module bundlers +If you're using a module bundler (Webpack, Vite, Rollup, Parcel, etc.), simply install and import the module as you would in Node.js. The bundler will automatically use the browser-compatible source files via the `browser` field in `package.json`: ```html @@ -101,11 +102,13 @@ QRCode.toCanvas(canvas, 'sample text', function (error) { }) ``` -#### Precompiled bundle +#### Precompiled bundle (for non-bundler usage) +If you're **not** using a module bundler and want to include the library directly via a ` + ``` -If you install through `npm`, precompiled files will be available in `node_modules/qrcode/build/` folder. +The precompiled bundle has support for [Internet Explorer 10+, Safari 5.1+, and all evergreen browsers](https://browserl.ist/?q=defaults%2C+IE+%3E%3D+10%2C+Safari+%3E%3D+5.1). -The precompiled bundle have support for [Internet Explorer 10+, Safari 5.1+, and all evergreen browsers](https://browserl.ist/?q=defaults%2C+IE+%3E%3D+10%2C+Safari+%3E%3D+5.1). +**Note:** Most modern projects use bundlers (Webpack, Vite, etc.) and don't need the precompiled bundle - just `npm install qrcode` and import it. ### NodeJS Require the module `qrcode` @@ -294,13 +297,13 @@ An helper method is provided by the lib through an optional file that you can in }) ``` -With precompiled bundle: +With precompiled bundle (run `npm run build` to generate these files): ```html - - + +