-
Notifications
You must be signed in to change notification settings - Fork 222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
crypto.randomBytes is not a function #398
Comments
This seems to be vue-cli specific problem. If application is running or built using vue-cli https://github.com/jprichardson/secure-random/blob/master/lib/secure-random.js#L20 |
I have filled a patch to secure-random. If it gets merged & released I will create a PR for steem-js to use new version. In other case I will release the new version myself so it is usable with vue-cli. |
I think I've solved your problem already, I release my version of library some time ago. Try to use this version of steem-js:
|
Hi thanks. I'll try to confirm the fix. |
Hi BartolomeoItalia, Unfortunately I still get the same error on the line:
|
Exactly the same problem, try to start my vue.js project with steem-js, but get an error. |
You can use https://github.com/jnordberg/dsteem |
@irelandscape - I have resolved this by the way with dsteem (using quasar 0.17.15): // /src/plugins/dsteem.js
import { Client } from 'dsteem'
export default ({ app, router, Vue }) => {
const steemClient = new Client('https://api.steemit.com')
Vue.prototype.$steemClient = steemClient
}
// script part in a vue SFC
export default {
name: 'Index',
data () {
return {
props: {
maximum_block_size: this.main()
}
}
},
methods: {
main: async function () {
await this.$steemClient.database.getChainProperties().then((props) => {
console.log(`Maximum blocksize consensus: ${props.maximum_block_size} bytes`)
this.props = props
})
}
}
} |
The solution of @Sekhmet worked for me. I had to clone both secure-random and steem-js, make the changes in secure-random, install it on steem-js and build steem-js. |
fix: update secure-random. fixes #398
Expected behavior
Should be able to import steem library into my vue,js project.
Actual behavior
Getting the following error:
[Vue warn]: Error in mounted hook: "TypeError: crypto.randomBytes is not a function"
on the following line:
var steem = require('steem')
The exception is thrown from the nodeRandom function in secure-random.js.
I put a breakpoint in that function and I can see that require('crypto') returns an empty object:
How to reproduce
I seem to be able to reproduce the problem by just invoking:
require('steem')
The reported error is in secure-random.js, in the function nodeRandom.
I have verified that I can invoke the crypto.randomBytes function directly from my application.
The following works:
console.log(require('crypto').randomBytes(64))
so I'm wondering if the steem library somehow messes up crypto.
Environment information
Using node 8.10 on Ubuntu 18.04
Application uses the Quasar UI framework with vue.js.
The text was updated successfully, but these errors were encountered: