Skip to content
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

forge does not load #215

Closed
ofersadgat opened this issue Jan 30, 2015 · 15 comments
Closed

forge does not load #215

ofersadgat opened this issue Jan 30, 2015 · 15 comments
Milestone

Comments

@ofersadgat
Copy link

With node.js, adding forge causes the javascript to halt on load with the error: "Uncaught Error: Cannot find module './aes'"

To reproduce:

npm install gulp gulp-browserify gulp-concat node-forge react reactify

gulpfile.js:

var gulp         = require('gulp');
var browserify   = require('gulp-browserify');
var concat       = require('gulp-concat');


gulp.task('browserify', function(){
    return gulp.src('src/js/main.jsx')
                .pipe(browserify({transform: 'reactify'}))
                .pipe(concat('out.js'))
                .pipe(gulp.dest('dist/js'));
})

gulp.task('html', function(){
    return gulp.src('src/index.html')
                .pipe(gulp.dest('dist'));
});

gulp.task('default', ['browserify', 'html']);

src/index.html:

<HTML>
  <head>

  </head>
  <body>
    <div id="client"></div>
    <script src="js/out.js"></script>
  </body>
</HTML>

src/js/main.jsx:

var React   = require('react');
var forge    = require('node-forge');

var App = React.createClass({
    render: function(){
        return (
            <div>There is no cake.</div>
        );
    }
});

React.render(<App />, document.getElementById('client'));
@dlongley
Copy link
Member

This is a problem we plan to fix with a new build system. See #126.

@iamolivinius
Copy link

Is there any way around this issue until the "new build system" is live?

@dlongley
Copy link
Member

dlongley commented Mar 3, 2015

@iamolivinius, unfortunately I'm swamped so I haven't had time to investigate getting forge working with browserify. Does anyone else have a good workaround?

There's always the option to load forge just as a regular bundled script (or a set of scripts) or use requirejs for the time being. Obviously that's not ideal in browserify environments, but it should work. You may be able to use a tool like deamdify to get around any other issues. I haven't tried it myself.

@iamolivinius
Copy link

Right now I use an npm install alias to bower forge and run its build script. There is no prebuild bundle in the repo, right?

I'm not so confident with all the module formats but my first idea would be to make use of the ES6 module syntax and https://github.com/esnext/es6-module-transpiler to transpile into the different module formats.

@ofersadgat
Copy link
Author

Yes, what I ended up doing was exactly as @dlongley said: I am including the bundled version and it seems to be working fine.

@dlongley
Copy link
Member

dlongley commented Mar 3, 2015

There is no prebuild bundle in the repo, right?

Right.

@henry74
Copy link

henry74 commented Mar 8, 2015

I have installed forge using bower and I'm trying to use it in an angularjs application. Do I need to inject anything to get it working? Right now it's failing with the following error:

TypeError: Cannot read property 'getBytesSync' of undefined

The line causing the problem is:

var salt = forge.random.getBytesSync(128);

It appears forge is a valid object, but random is not...

@mikemaccana
Copy link

Hrm was hoping to test node-forge as an alternate to asn1js / pkijs and also getting Cannot find module './aes' Any updates on the new build system? I'd like to avoid hacking the module if possible.

@acasajus
Copy link

I'm also interested in this. Is there any news on this?

@dlongley
Copy link
Member

@mikemaccana,

Can you provide more details about how you're loading forge so we can try and help determine the problem? Can you generate and use the bundled version like others have?

@acasajus,

No updates on this front yet, but further discussion/ideas over at #126 or PRs are welcome.

@raed667
Copy link

raed667 commented May 3, 2016

:bump:

Is there an update on this ?

@dlongley
Copy link
Member

dlongley commented May 3, 2016

@davidlehn -- can we get an update over at #357?

@raed667
Copy link

raed667 commented May 3, 2016

@dlongley : This is easily avoidable on the user part, by decoupling what they want to do with browserify form forge and then using forge.min.js in the browser to get the same behavior.

It took me 5 minutes of copy pasting.

@jbollam
Copy link

jbollam commented Jul 12, 2016

@henry74 use forge.min.js file this iwll resolve your error.

@davidlehn davidlehn added this to the v0.7.0 milestone Jan 12, 2017
@davidlehn
Copy link
Member

0.7.0 was released with a new build system which should address this issue. Reopen if it's still a problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants