Jint.CommonJS
Jint.CommonJS copied to clipboard
node Require
Hello,
Thank you for providing this extension to Jint!
You are not able to load npm packages with Jint.CommonJS. Although the library loads modules in relatively the same format at NodeJS's Module specification, there are some important distinctions. The library does not support node_modules, or reading package.json files for modules.
Do you know of any Jint extension that can handle basic node require
s (no package.json)?
Thanks, Ben
Hi Ben,
Apologies for the hiatus and delayed reply, although unfortunately you may not derive too much use out of this either way.
Do you know of any Jint extension that can handle basic node requires (no package.json)?
Basic node
requires is exactly what the library does, as Jint.CommonJS and node.JS both implement the CommonJS spec with a few important distinctions which I think you might have your wires crossed with. Jint.CommonJS doesn't support node_modules not because of arbitrary decision, but because Jint.NET isn't node.js: NPM modules assume the presence of a node.js or browser environment which will never work unless you specifically emulate an entire node.js runtime (the presence of the process
global, require('fs')
, the Window
global et al) or almost every module loaded via Jint.CommonJS
will fail to execute.
However, Jint.CommonJS will happily load from a node_modules
path if it's specified directly so I'm curious as to your use case.
Cheers, Tyler.
Thanks, @tylerjwatson. My apologies for the long delayed reply, as well. :-)
I had been trying to use Jint.Net to load https://github.com/Microsoft/powerquery-parser then do a simple parse (like something from https://github.com/microsoft/powerquery-parser/blob/master/src/example.ts). Startup would die due to being unable to load all the requires....