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

Getting an error "Can't resolve 'os'" #238

Open
dagumak opened this issue Jan 4, 2022 · 1 comment
Open

Getting an error "Can't resolve 'os'" #238

dagumak opened this issue Jan 4, 2022 · 1 comment

Comments

@dagumak
Copy link

dagumak commented Jan 4, 2022

I am using node v16.13.0 and Gatsby. This is what happens after I install parallel.js and imported it in my code. I am not really sure what the issue is.

import Parallel from 'paralleljs';

const p = new Parallel([0, 1, 2, 3, 4, 5, 6]);
const log = function () { console.log(arguments); };
 ERROR #98124  WEBPACK

Generating development JavaScript bundle failed

Can't resolve 'os' in '/Users/hello/projects/example/yoyo/app/node_modules/paralleljs/lib'

If you're trying to use a package make sure that 'os' is installed. If you're trying to use a local file make sure that the path is correct.

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
	- add a fallback 'resolve.fallback: { "os": require.resolve("os-browserify/browser") }'
	- install 'os-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
	resolve.fallback: { "os": false }

File: node_modules/paralleljs/lib/parallel.js:81:8
@Ahmed-ShawkyEgy
Copy link

Not sure if that helps, but you can try installing this pollyfill.

run
npm install node-polyfill-webpack-plugin

then add the following to your config

const NodePolyfillPlugin = require('node-polyfill-webpack-plugin');

module.exports = {
	// Other rules...
	plugins: [
		new NodePolyfillPlugin()
	]
};

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

No branches or pull requests

2 participants