mnater / Hyphenopoly

Hyphenation for node and Polyfill for client-side hyphenation.
http://mnater.github.io/Hyphenopoly/
MIT License
689 stars 45 forks source link

get "Module not found: Error:" #188

Closed mamitry closed 2 years ago

mamitry commented 2 years ago

Using this in a vue app:

import hyphenopoly from "hyphenopoly";

const hyphenator = hyphenopoly.config({
  require: ["de", "en-us", "cop"],
  hyphen: "•",
  exceptions: {
    "en-us": "en-han-ces",
  },
});

i get this error:

[vue-cli-service] INFO Starting development server... Build finished at 03:24:37 by 0.000s [vue-cli-service] error in ./node_modules/hyphenopoly/hyphenopoly.module.js [vue-cli-service] Module not found: Error: Can't resolve 'path' in 'D:\myproject\node_modules\hyphenopoly' [vue-cli-service] BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. [vue-cli-service] This is no longer the case. Verify if you need this module and configure a polyfill for it. [vue-cli-service] If you want to include a polyfill, you need to: [vue-cli-service] - add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }' [vue-cli-service] - install 'path-browserify' [vue-cli-service] If you don't want to include a polyfill, you can use an empty module like this:
[vue-cli-service] resolve.fallback: { "path": false } [vue-cli-service] error in ./node_modules/hyphenopoly/hyphenopoly.module.js [vue-cli-service] Module not found: Error: Can't resolve 'url' in 'D:\myproject\node_modules\hyphenopoly' [vue-cli-service] BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. [vue-cli-service] This is no longer the case. Verify if you need this module and configure a polyfill for it. [vue-cli-service] If you want to include a polyfill, you need to: [vue-cli-service] - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
[vue-cli-service] - install 'url' [vue-cli-service] If you don't want to include a polyfill, you can use an empty module like this:
[vue-cli-service] resolve.fallback: { "url": false } [vue-cli-service] error in ./node_modules/hyphenopoly/hyphenopoly.module.js [vue-cli-service] Module not found: Error: Can't resolve 'fs' in 'D:\myproject\node_modules\hyphenopoly' [vue-cli-service] error in ./node_modules/hyphenopoly/hyphenopoly.module.js [vue-cli-service] Module not found: Error: Can't resolve 'https' in 'D:\myproject\node_modules\hyphenopoly' [vue-cli-service] BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. [vue-cli-service] This is no longer the case. Verify if you need this module and configure a polyfill for it. [vue-cli-service] If you want to include a polyfill, you need to: [vue-cli-service] - add a fallback 'resolve.fallback: { "https": require.resolve("https-browserify") }' [vue-cli-service] - install 'https-browserify' [vue-cli-service] If you don't want to include a polyfill, you can use an empty module like this:
[vue-cli-service] resolve.fallback: { "https": false } Build finished at 03:24:37 by 0.000s

[INFO] Development server running!

   Local: http://localhost:8100

   Use Ctrl+C to quit this process

[INFO] Browser window opened to http://localhost:8100! ERROR in ./node_modules/hyphenopoly/hyphenopoly.module.js 12:0-29 [vue-cli-service] Module not found: Error: Can't resolve 'path' in 'D:\myproject\node_modules\hyphenopoly' [vue-cli-service] BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. [vue-cli-service] This is no longer the case. Verify if you need this module and configure a polyfill for it. [vue-cli-service] If you want to include a polyfill, you need to: [vue-cli-service] - add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }' [vue-cli-service] - install 'path-browserify' [vue-cli-service] If you don't want to include a polyfill, you can use an empty module like this: [vue-cli-service] resolve.fallback: { "path": false } [vue-cli-service] @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/VarusText.vue?vue&type=script&setup=true&lang=js 1:0-38 32:23-41 50:6-17 [vue-cli-service] @ ./src/components/VarusText.vue?vue&type=script&setup=true&lang=js 1:0-212 1:0-212 1:213-414 1:213-414 [vue-cli-service] @ ./src/components/VarusText.vue 2:0-71 3:0-66 3:0-66 6:49-55 [vue-cli-service] @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/VarusChapterMenuList.vue?vue&type=script&setup=true&lang=js 4:0-40 32:6-15 [vue-cli-service] @ ./src/components/VarusChapterMenuList.vue?vue&type=script&setup=true&lang=js 1:0-223 1:0-223 1:224-436 1:224-436 [vue-cli-service] @ ./src/components/VarusChapterMenuList.vue 2:0-82 3:0-77 3:0-77 8:49-55 [vue-cli-service] @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/views/BooksDetails.vue?vue&type=script&setup=true&lang=js 5:0-74 101:6-26 [vue-cli-service] @ ./src/views/BooksDetails.vue?vue&type=script&setup=true&lang=js 1:0-215 1:0-215 1:216-420 1:216-420 [vue-cli-service] @ ./src/views/BooksDetails.vue 2:0-74 3:0-69 3:0-69 6:49-55 [vue-cli-service] @ ./src/router/index.js 23:19-54 [vue-cli-service] @ ./src/main.js 8:0-30 44:55-61 46:0-14 [vue-cli-service] ERROR in ./node_modules/hyphenopoly/hyphenopoly.module.js 13:0-34 [vue-cli-service] Module not found: Error: Can't resolve 'url' in 'D:\myproject\node_modules\hyphenopoly' [vue-cli-service] BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. [vue-cli-service] This is no longer the case. Verify if you need this module and configure a polyfill for it. [vue-cli-service] If you want to include a polyfill, you need to: [vue-cli-service] - add a fallback 'resolve.fallback: { "url": require.resolve("url/") }' [vue-cli-service] - install 'url' [vue-cli-service] If you don't want to include a polyfill, you can use an empty module like this: [vue-cli-service] resolve.fallback: { "url": false } [vue-cli-service] @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/VarusText.vue?vue&type=script&setup=true&lang=js 1:0-38 32:23-41 50:6-17 [vue-cli-service] @ ./src/components/VarusText.vue?vue&type=script&setup=true&lang=js 1:0-212 1:0-212 1:213-414 1:213-414 [vue-cli-service] @ ./src/components/VarusText.vue 2:0-71 3:0-66 3:0-66 6:49-55 [vue-cli-service] @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/VarusChapterMenuList.vue?vue&type=script&setup=true&lang=js 4:0-40 32:6-15 [vue-cli-service] @ ./src/components/VarusChapterMenuList.vue?vue&type=script&setup=true&lang=js 1:0-223 1:0-223 1:224-436 1:224-436 [vue-cli-service] @ ./src/components/VarusChapterMenuList.vue 2:0-82 3:0-77 3:0-77 8:49-55 [vue-cli-service] @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/views/BooksDetails.vue?vue&type=script&setup=true&lang=js 5:0-74 101:6-26 [vue-cli-service] @ ./src/views/BooksDetails.vue?vue&type=script&setup=true&lang=js 1:0-215 1:0-215 1:216-420 1:216-420 [vue-cli-service] @ ./src/views/BooksDetails.vue 2:0-74 3:0-69 3:0-69 6:49-55 [vue-cli-service] @ ./src/router/index.js 23:19-54 [vue-cli-service] @ ./src/main.js 8:0-30 44:55-61 46:0-14 [vue-cli-service] ERROR in ./node_modules/hyphenopoly/hyphenopoly.module.js 19:0-24 [vue-cli-service] Module not found: Error: Can't resolve 'fs' in 'D:\myproject\node_modules\hyphenopoly' [vue-cli-service] @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/VarusText.vue?vue&type=script&setup=true&lang=js 1:0-38 32:23-41 50:6-17 [vue-cli-service] @ ./src/components/VarusText.vue?vue&type=script&setup=true&lang=js 1:0-212 1:0-212 1:213-414 1:213-414 [vue-cli-service] @ ./src/components/VarusText.vue 2:0-71 3:0-66 3:0-66 6:49-55 [vue-cli-service] @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/VarusChapterMenuList.vue?vue&type=script&setup=true&lang=js 4:0-40 32:6-15 [vue-cli-service] @ ./src/components/VarusChapterMenuList.vue?vue&type=script&setup=true&lang=js 1:0-223 1:0-223 1:224-436 1:224-436 [vue-cli-service] @ ./src/components/VarusChapterMenuList.vue 2:0-82 3:0-77 3:0-77 8:49-55 [vue-cli-service] @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/views/BooksDetails.vue?vue&type=script&setup=true&lang=js 5:0-74 101:6-26 [vue-cli-service] @ ./src/views/BooksDetails.vue?vue&type=script&setup=true&lang=js 1:0-215 1:0-215 1:216-420 1:216-420 [vue-cli-service] @ ./src/views/BooksDetails.vue 2:0-74 3:0-69 3:0-69 6:49-55 [vue-cli-service] @ ./src/router/index.js 23:19-54 [vue-cli-service] @ ./src/main.js 8:0-30 44:55-61 46:0-14 [vue-cli-service] ERROR in ./node_modules/hyphenopoly/hyphenopoly.module.js 130:8-23 [vue-cli-service] Module not found: Error: Can't resolve 'https' in 'D:\myproject\node_modules\hyphenopoly' [vue-cli-service] BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default. [vue-cli-service] This is no longer the case. Verify if you need this module and configure a polyfill for it. [vue-cli-service] If you want to include a polyfill, you need to: [vue-cli-service] - add a fallback 'resolve.fallback: { "https": require.resolve("https-browserify") }' [vue-cli-service] - install 'https-browserify' [vue-cli-service] If you don't want to include a polyfill, you can use an empty module like this: [vue-cli-service] resolve.fallback: { "https": false } [vue-cli-service] @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/VarusText.vue?vue&type=script&setup=true&lang=js 1:0-38 32:23-41 50:6-17 [vue-cli-service] @ ./src/components/VarusText.vue?vue&type=script&setup=true&lang=js 1:0-212 1:0-212 1:213-414 1:213-414 [vue-cli-service] @ ./src/components/VarusText.vue 2:0-71 3:0-66 3:0-66 6:49-55 [vue-cli-service] @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/VarusChapterMenuList.vue?vue&type=script&setup=true&lang=js 4:0-40 32:6-15 [vue-cli-service] @ ./src/components/VarusChapterMenuList.vue?vue&type=script&setup=true&lang=js 1:0-223 1:0-223 1:224-436 1:224-436 [vue-cli-service] @ ./src/components/VarusChapterMenuList.vue 2:0-82 3:0-77 3:0-77 8:49-55 [vue-cli-service] @ ./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/views/BooksDetails.vue?vue&type=script&setup=true&lang=js 5:0-74 101:6-26 [vue-cli-service] @ ./src/views/BooksDetails.vue?vue&type=script&setup=true&lang=js 1:0-215 1:0-215 1:216-420 1:216-420
[vue-cli-service] @ ./src/views/BooksDetails.vue 2:0-74 3:0-69 3:0-69 6:49-55 [vue-cli-service] @ ./src/router/index.js 23:19-54 [vue-cli-service] @ ./src/main.js 8:0-30 44:55-61 46:0-14 [vue-cli-service] webpack compiled with 4 errors

mnater commented 2 years ago

Hi

It is not recommended to use the Node module in a browser context. Instead, the Hyphenoply loader should be included. This can ensure that the browser does not load the entire package unnecessarily if it already supports hyphenation natively.

Now, I don't know the exact use case, but I'll try to give some guidance anyway. In my opinion, the error messages are quite clear: the Node module needs the functions "path", "url" and "https", which are no longer automatically available as a polyfill since Webpack 5 and have to be installed manually. If these are installed according to the instructions in the error messages, it should theoretically work (untested).

mnater commented 2 years ago

I close this issue, because there was no activity in the last 2 months. Feel free to reopen anytime.