https://github.com/rookiemonkey/boilerplate-npm_on_browser
:wrench: :hammer: An example on how to use node modules on browser instead of a nodejs environment. WARNING :bangbang: not all node modules will work on browsers
https://github.com/rookiemonkey/boilerplate-npm_on_browser
boilerplate browserify template
Last synced: over 1 year ago
JSON representation
:wrench: :hammer: An example on how to use node modules on browser instead of a nodejs environment. WARNING :bangbang: not all node modules will work on browsers
- Host: GitHub
- URL: https://github.com/rookiemonkey/boilerplate-npm_on_browser
- Owner: rookiemonkey
- Created: 2020-11-17T01:00:40.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-11-17T01:18:29.000Z (over 5 years ago)
- Last Synced: 2025-02-08T12:12:56.962Z (over 1 year ago)
- Topics: boilerplate, browserify, template
- Language: JavaScript
- Homepage:
- Size: 49.8 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
1. require the npm package the you need
```
const Buffer = require('buffer').Buffer
```
2. Append the variable to the window object
```
global.window.Buffer = Buffer
```
3. Install browserify as devDep
```
yarn add browserify -D
```
4. Compile your main.js file using browserify
```
browserify main.js -o output.js
```
5. use your output.js on your html
```
```
6. run it on live server and check the window object on console if your npm
package is present (in this example, it is Buffer)
