forge icon indicating copy to clipboard operation
forge copied to clipboard

SyntaxError in node's strict mode (--use_stict)

Open tsabolov opened this issue 10 years ago • 11 comments

Trying to require library in strict mode of node (node --use_strict) causes a SyntaxError:

let forge = require('node-forge');
SyntaxError: Delete of an unqualified identifier in strict mode.

The error is caused by the following line in file /js/forge.js:

delete define;

AFAIK, in strict it's prohibited to delete global variables (properties of global object) this way. Please fix this behaviour in order to make the library work in strict mode.

tsabolov avatar Dec 11 '15 12:12 tsabolov

This is related to item 6 of the roadmap: #203

We need to update the packaging system for forge, removing handcrafted boilerplate and replacing it with something that is auto-generated and that supports a variety of different package/module loading APIs/mechanisms.

dlongley avatar Dec 11 '15 16:12 dlongley

+1 Any temporary solution for this issue?

dev0x10 avatar Jan 07 '16 16:01 dev0x10

Personally I have ended up rewriting my files to have 'use strict'; in the beginning, and now I'm running node without --use_strict flag. This way everything is working like a charm.

tsabolov avatar Jan 07 '16 16:01 tsabolov

I'm using webpack to build my js file which means 'use strict' will included in my bundle file. In the end I have to do plain copy forge.min.js without compile it into my bundle js

dev0x10 avatar Jan 07 '16 17:01 dev0x10

My pull request that removes RequireJS and uses Webpack instead also runs all non-browser tests with strict mode without problems: https://github.com/digitalbazaar/forge/pull/357

ysangkok avatar Feb 09 '16 03:02 ysangkok

+1

irtazabbas avatar Apr 12 '16 07:04 irtazabbas

Any permanent fix coming to this?

ErkanSensei avatar Apr 22 '16 07:04 ErkanSensei

Any permanent fix coming to this?

cc: @davidlehn -- can we get a synopsis of the remaining challenges over at #357? There's also an offer of assistance over there.

dlongley avatar Apr 22 '16 13:04 dlongley

+1

andreassolberg avatar Jul 05 '16 05:07 andreassolberg

+1

ghost avatar Dec 01 '16 11:12 ghost

Should be addressed in a new release now that #456 has been merged.

dlongley avatar Jan 11 '17 16:01 dlongley