Comments (4)
I have done some investigations. From my test the problem is inside htmlparser2
module, only in version 3.10.1, the version used by cheerio.
It contains the following code: require("entities/maps/entities.json")
.
But the correct path is require("entities/lib/maps/entities.json");
(with lib
).
Here a simple test.
- create a new node project
- install entities:
npm i entities
- create a new index.js file with:
require("entities/maps/entities.json")
- run it
I get an error module not found. Like with live-plugin-manager
.
If you look at the latest version of htmlparser2, https://github.com/fb55/htmlparser2/blob/master/src/Tokenizer.ts, the code is now correct.
A quick workaround, until cheerio is update htmlparser2 version, is to just install the latest version (4.0.0) of htmlparser2 after cheerio.
Here an unit test:
it("issue 14: installing cheerio", async function() {
await manager.installFromNpm("cheerio", "1.0.0-rc.3");
await manager.installFromNpm("htmlparser2", "4.0.0");
const cheerio = manager.require("cheerio");
assert.isDefined(cheerio, "Plugin is not loaded");
// try to use the plugin
const $ = cheerio.load('<h2 class="title">Hello world</h2>')
$('h2.title').text('Hello there!')
$('h2').addClass('welcome')
assert.equal($.html(), '<html><head></head><body><h2 class="title welcome">Hello there!</h2></body></html>');
});
See also: cheeriojs/cheerio#1339 (comment)
from live-plugin-manager.
I think that you are right. The bug is related probably to the fact that the main file is inside a subdirectory, lib
. Strange that I never see this problem in other modules... seems to be quite common.
Regarding the fix I'm now sure. I need some more time to investigate ...
If you are able to publish a pull request I appreciate. Probably we need to try to reproduce it in one of the unit test, it should be quite easy I hope.
Thank you for the bug report
from live-plugin-manager.
Sorry for the delay, I've added a pull request with my fix. I don't think it's particularly robust though, but it does fix requiring Cheerio from within the VM.
from live-plugin-manager.
Let me know if you are able to use the proposed workaround (install version 4 of htmlparser2)
from live-plugin-manager.
Related Issues (20)
- 'window.webkitStorageInfo' is deprecated. Please use 'navigator.webkitTemporaryStorage' or 'navigator.webkitPersistentStorage' instead. HOT 3
- 0.14.1 -> 0.15.1 issue on 0.15.1 HOT 2
- no such file or directory, mkdir '/plugin_packages' HOT 4
- getInfo should load the package from disk HOT 2
- Proxy settings for NPM registry HOT 1
- Support loading plugins without FS access HOT 1
- fix: circular dependencies result in endless loop + out of memory crash HOT 3
- Plugin manager require gives module not found but passing the path directly works HOT 4
- Plugin manager gives an error requiring aws-sdk HOT 3
- sharp lib install failed HOT 2
- Error when using require to load an ES6 module HOT 7
- PluginManager.install is not compatible with NodeJS workers HOT 1
- Literal Object prototype is not working properly inside the plugin's context HOT 9
- Module not found: Can't resolve 'console' in React HOT 2
- Error: Invalid plugin github repository HOT 2
- Improper Error handling HOT 1
- PluginVm.getScopedInfo could not get the correct scope if it contains a dot HOT 1
- Handling modules with index.json entrypoints HOT 2
- FR: Support for `"exports"` in `package.json` HOT 1
- Error: Code generation from strings disallowed for this context HOT 2
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 live-plugin-manager.