“Cannot find module”

Hi! Thanks for making this possible on iOS! I have an issue trying to use htmlparser2 with play.js, as shown here:

{ Error: Cannot find module 'entities/maps/entities.json'
   at Module._resolveFilename (internal/modules/cjs/loader.js:582:5)
   at Module._load (internal/modules/cjs/loader.js:506:3)
   at Module.prototype.require (internal/modules/cjs/loader.js:639:3)
   at require (internal/modules/cjs/helpers.js:20:7)
   at Anonymous function (/private/var/mobile/Containers/Shared/AppGroup/1B007F5C-CB25-41D7-A753-C31710764F1E/File Provider Storage/Repositories/slugsurvival/ucsc/node_modules/htmlparser2/lib/Tokenizer.js:4:1)
   at Module.prototype._compile (internal/modules/cjs/loader.js:702:5)
   at Module._extensions[.js] (internal/modules/cjs/loader.js:713:3)
   at Module.prototype.load (internal/modules/cjs/loader.js:601:3)
   at tryModuleLoad (internal/modules/cjs/loader.js:537:5)
   at Module._load (internal/modules/cjs/loader.js:529:3) code: 'MODULE_NOT_FOUND' }

It looks like Tokenizer.js in htmlparser2 is trying to load files in the entities module:

module.exports = Tokenizer;

var decodeCodePoint = require("entities/lib/decode_codepoint.js");
var entityMap = require("entities/maps/entities.json");
var legacyMap = require("entities/maps/legacy.json");
var xmlMap = require("entities/maps/xml.json");

I can see that there’s duplicate question in Node.js “Cannot find module” error, however I’m not sure of if this is specific project’s problem, or the loader cannot resolve to the correct module.

Could this be a bug?

It seems that htmlparser2 wants entities@1.x, but for some reasons, play.js resolving dependency downloaded entities@2.x instead

Hi @lucky.autumn :wave:

Thanks for reporting. I’ll take a look and see why the incorrect version is being fetched.

package.json and package-lock.json all have 1.x in htmlparser2, and the cheerio package I’m using requires the htmlparser2 package. If you would like to debug, please use cheerio in the index.js.

here’s the link for testing: playdotjs://29139f0a

cheerio explicitly requires entities@1.x and htmlparser2@3.9x, and checking node_modules find that entities@2.x and htmlparser2@3.10x were installed.

Hi again @lucky.autumn :wave:

The issue has been identified and a fix will be part of the next release.

Thanks for your help getting this sorted :bowing_man:.

Would you indulge my curiosity as of what the issue was?

1 Like

The semantic versioning checker was completely broken due to a text encoding issue :disappointed_relieved:.

big æuf :upside_down_face:

I guess now… more unit testing!

1 Like