Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

url polyfill for webpack 5 #466

Merged
merged 1 commit into from
May 23, 2024
Merged

Conversation

NC-jsAhonen
Copy link
Contributor

@NC-jsAhonen NC-jsAhonen commented Mar 5, 2024

I got the following error trying to run develop with yarn start, so I created these changes.

ERROR in ./src/index.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module 'fs/promises'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/home/jukka-ahonen/CustomerProjects/City-of-Helsinki/mvj-ui/node_modules/babel-loader/lib/cache.js:21:5)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)

ERROR in ./src/silent_renew.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module 'fs/promises'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/home/jukka-ahonen/CustomerProjects/City-of-Helsinki/mvj-ui/node_modules/babel-loader/lib/cache.js:21:5)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)

ERROR in ./src/main.scss (./node_modules/css-loader/dist/cjs.js!./node_modules/sass-loader/dist/cjs.js!./src/main.scss)
Module build failed (from ./node_modules/sass-loader/dist/cjs.js):
Error: Missing binding /home/jukka-ahonen/CustomerProjects/City-of-Helsinki/mvj-ui/node_modules/node-sass/vendor/linux-x64-64/binding.node
Node Sass could not find a binding for your current environment: Linux 64-bit with Node.js 10.x

Found bindings for the following environments:
  - OS X 64-bit with Node.js 18.x
  - OS X 64-bit with Node.js 19.x
  - OS X 64-bit with Node.js 16.x
  - Linux 64-bit with Node.js 18.x

This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to download the binding for your current environment.
    at module.exports (/home/jukka-ahonen/CustomerProjects/City-of-Helsinki/mvj-ui/node_modules/node-sass/lib/binding.js:15:13)
    at Object.<anonymous> (/home/jukka-ahonen/CustomerProjects/City-of-Helsinki/mvj-ui/node_modules/node-sass/lib/index.js:13:35)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at getDefaultSassImplementation (/home/jukka-ahonen/CustomerProjects/City-of-Helsinki/mvj-ui/node_modules/sass-loader/dist/utils.js:36:10)
 @ ./src/main.scss 8:6-139 22:17-24 26:7-21 52:25-39 53:36-47 53:50-64 57:6-67:7 58:54-65 58:68-82 64:42-53 64:56-70 66:21-28 77:0-109 77:0-109 78:22-29 78:33-47 78:50-64 55:4-68:5

webpack 5.90.0 compiled with 3 errors in 2812 ms

@henrinie-nc
Copy link
Contributor

@NC-jsAhonen Was there some issue with this?

@NC-jsAhonen NC-jsAhonen requested a review from henrinie-nc March 12, 2024 05:10
@NC-jsAhonen
Copy link
Contributor Author

@NC-jsAhonen Was there some issue with this?

I wrote it to the description. But this is not necessary for the demo if the develop works in other environments.

Copy link
Contributor

@henrinie-nc henrinie-nc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@NC-jsAhonen You need to run mvj-ui's yarn start with minimum node v18. Please try that. Also delete node_modules and reinstall them

@NC-jsAhonen
Copy link
Contributor Author

Now I managed to make it work. Closing this PR, as it is outdated.

@@ -8,6 +8,9 @@ if (typeof Promise === 'undefined') {
window.Promise = require('promise/lib/es6-extensions.js');
}

// for webpack 5
require('url')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me with just the "url" package installed. So maybe this part is redundant?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for me

package.json Outdated
@@ -69,6 +69,7 @@
"redux-form": "^8.2.5",
"redux-oidc": "^3.1.4",
"redux-saga": "^1.0.5",
"url": "^0.11.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose this should be a dev dependency?

@henrinie-nc
Copy link
Contributor

The reason why it worked for me seems to be that I had the package installed globally, and webpack included it from there. After removing said package, I get the same error.
I propose we add the package url, but as a development dependency, and not do the polyfill (I didn't have a problem without it)

@NC-jsAhonen NC-jsAhonen force-pushed the fix/url-polyfill-for-webpack-5 branch from a9f3caf to 8f54f14 Compare May 22, 2024 07:14
@NC-jsAhonen NC-jsAhonen force-pushed the fix/url-polyfill-for-webpack-5 branch from 8f54f14 to be3a203 Compare May 22, 2024 07:18
@NC-jsAhonen NC-jsAhonen merged commit 886ea9c into develop May 23, 2024
3 checks passed
@juho-kettunen-nc juho-kettunen-nc deleted the fix/url-polyfill-for-webpack-5 branch December 4, 2024 06:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants