Comments (12)
This is an issue with the bundler and not necessarily node-uuid. However, node-uuid could solve it by having an alternate entry point when the package is required in a browser context by using the "browser" key in package.json. See https://github.com/crypto-browserify/randombytes for an example on how to do that. The bundlers aren't smart enough to see that 'crypto'
and Buffer
are only used conditionally if the window
global is defined.
With the current version of node-uuid, you can prevent from bloating your bundle with browserify or other bundlers by configuring them bundler to ignore or shim 'crypto'
and 'Buffer'
to empty objects. The conditionals in node-uuid don't use them if the window
global exists anyway. Modern browsers offer window.crypto
or window.msCrypto
which node-uuid will use instead and then fall back to a built-in random number generator if the browser doesn't supply a crypto library.
In browserify, you can use --ignore
or b.ignore()
to ignore the 'crypto'
and 'buffer'
packages. I believe webpack has an IgnorePlugin that works similarly.
from uuid.
Just ran into this as well. Looks like that commit hasn't been published to npm yet. There hasn't been a publish in almost a year.
$ npm info node-uuid time
{ modified: '2013-12-28T11:49:54.162Z',
created: '2012-02-06T13:13:29.968Z',
'1.3.3': '2012-02-06T19:00:02.414Z',
'1.2.0': '2012-02-06T18:37:58.432Z',
'1.3.0': '2012-02-06T18:43:49.454Z',
'1.3.1': '2012-02-06T18:46:09.071Z',
'1.3.2': '2012-02-06T18:49:48.386Z',
'1.1.0': '2012-02-06T18:54:52.771Z',
'1.0.0': '2012-02-06T18:56:53.955Z',
'1.4.0': '2012-10-18T13:51:34.289Z',
'1.4.1': '2013-08-17T12:51:06.146Z' }
from uuid.
Also having an issue with this. The bigger problem is that rng.js doesn't seem to be compatible with Firefox or Safari because window.crypto.getRandomValues breaks when a shimmed Buffer is passed into it.
I'm able to solve the problem by changing line 25 of rng.js from
var bytes = new Buffer(size); //in browserify, this is an extended Uint8Array
to
var bytes = new Uint8Array(size); //in browserify, this is an extended Uint8Array
Unfortunately, I can't find a way to do this with Browserify or by monkey-patching - editing the file directly is the only solution (which clearly isn't ideal or sustainable).
from uuid.
Follow up: that's rng.js
in https://github.com/dominictarr/crypto-browserify. Technically, the problem I'm seeing is a bug there, but it can probably be fixed by preventing node-uuid from shimming crypto.
from uuid.
After further research, node-uuid doesn't seem to shim crypto or Buffer directly, but if crypto or Buffer is shimmed by another module, it will probably break node-uuid.
from uuid.
@ianwremmel did you settle on a solution for this problem? i'm running into it too.
from uuid.
I found the other places that were shimming Buffer and removed them. If nothing else shims Buffer, node-uuid won't shim it; if it's not available, node-uuid works just fine.
Avoiding Buffer is probably a good general guideline anyway. The Buffer shim is rather large and there's usually only a very small change need to avoid using it.
from uuid.
I fixed this is the "uuid" npmjs package (which is not this current repository, lulz) like this: defunctzombie@a33d3e0
from uuid.
thanks @vvo
So we have to do npm install uuid
instead of npm install node-uuid
right? Does it solve the @ianwremmel problem is Firefox? I have it too
from uuid.
So yes, in my case updating to package uuid
in last version solved this error for me:
TypeError: Argument 1 of Crypto.getRandomValues does not implement interface ArrayBufferView.
from uuid.
great!
from uuid.
Is this still an issue?
from uuid.
Related Issues (20)
- Double spaces in the deprecation message HOT 1
- Vulnerable dependencies (indirect security issues) HOT 2
- NPM Deprication Message is ambiguous HOT 2
- Question: Do we still need it?
- Sponsored issue: Incremental UUID HOT 1
- [BUG] uncorrect validation uuid HOT 1
- [question] is posible decode uuid to data back ? HOT 1
- Add UUID type to use in TypeScript HOT 1
- validate method returns false for a valid UUID HOT 6
- Issue in the import statement HOT 1
- [BUG] Installing `uuid` has an inconsistent dependency chain causing build issues in ci/cd pipelines HOT 2
- uuidv6 has been officially adopted by the IETF HOT 3
- Tracking Issue: RFC 9562 / uuid@10 HOT 1
- Make `Uint8Array` the one and only type used for binary (byte) uuid values
- Drop support for `offset` argument, commit to `Uint8Array` type for binary uuids
- Add v8 Support HOT 1
- Port codebase to TypeScript HOT 1
- v7: passing `options.msecs` results in zero-value timestamp HOT 5
- Error: Cannot find module 'node:crypto' when I upgrade uuid version from 9.0.0. to 10.0.0 HOT 4
- Reduce package size by code splitting HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uuid.