-
-
Notifications
You must be signed in to change notification settings - Fork 36
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
Module not found: Error: Can't resolve 'stream' #10
Comments
what are you using to bundle the module and do you have some non-default settings related to node built in modules? |
@calvinmetcalf angular-cli disables node packages in webpack config and does not have an option for enabling |
@artaommahe this sounds like It might be a problem with angular-cli then |
@calvinmetcalf it's an issue with any build pipeline that does not use default node packages. We can use universal versions instead to avoid such problems https://github.com/webpack/node-libs-browser |
this was written to be part of node-libs-browser so it assumes that those are already present, if it didn't then people who used node-libs-package might get multiple versions of dependencies bundled into the app which is something we'd like to avoid. |
If anyone's still having issues with this, you can fix it in your Angular project using tsconfig paths to point to a browser-compatible "compilerOptions": {
"paths": {
"stream": ["./node_modules/readable-stream"]
}
}, |
The above didn't help for our react native project built with React. After adding solution from kyranjamie we still get the error. |
patch-package helped me: in the package.json add this line:
opend the problem file and correct it. In my case: var Buffer = require('safe-buffer').Buffer
var Transform = require('readable-stream').Transform // replacing instead of "stream"
var StringDecoder = require('string_decoder').StringDecoder
var inherits = require('inherits')
function CipherBase (hashMode) {
... run the command from a root dir of your probject: it'll create a new folder patches in the root dir and add there this fix. That's all. Commit changes. It'll automaticaly replace code in the node_modules after reinstalling packages |
Merci j'avais un problème avec CipherBase sur mon projet j'ai modifier le package.json .. |
Perfect solution |
Is this a general issue with the package or does it only occur in specific situations? I would prefer having an upstream rather than patching up the package in production. |
I have the same issue with webpack 5, when using pollyfils like this:
I get the following error message:
|
perfect!!! |
…ebpack 5 This should fix browserify#10. --- This library makes use of the `stream` module. This is a Node API that's no longer polyfilled by Webpack 5. Anyone who depends upon `cipher-base` won't be able to upgrade their project to Webpack 5. Webpack will fail to build their project, citing that `stream` is missing. This also implies that anyone trying to use `cipher-base` with Create React App 5 won't be able to either, since CRA5 uses Webpack 5. Here's an example of folks in the Web3 community having trouble with this: anza-xyz/wallet-adapter#241
…ebpack 5 This should fix browserify#10. --- This library makes use of the `stream` module. This is a Node API that's no longer polyfilled by Webpack 5. Anyone who depends upon `cipher-base` won't be able to upgrade their project to Webpack 5. Webpack will fail to build their project, citing that `stream` is missing. This also implies that anyone trying to use `cipher-base` with Create React App 5 won't be able to either, since CRA5 uses Webpack 5. Here's an example of folks in the Web3 community having trouble with this: anza-xyz/wallet-adapter#241
…ebpack 5 This should fix browserify#10. --- This library makes use of the `stream` module. This is a Node API that's no longer polyfilled by Webpack 5. Anyone who depends upon `cipher-base` won't be able to upgrade their project to Webpack 5. Webpack will fail to build their project, citing that `stream` is missing. This also implies that anyone trying to use `cipher-base` with Create React App 5 won't be able to either, since CRA5 uses Webpack 5. Here's an example of folks in the Web3 community having trouble with this: anza-xyz/wallet-adapter#241
if anyone's wandered here from react/ts (me) downgrading
|
@remxx suggestion fixed it for me 🥳 !
The issue for me stemmed from installing web3js. I believe by downgrading the scripts you are switching to Webpack 4 which poly fills some node core libraries. |
|
This works fine on the latest versions on React! |
while a node module exposed to web we are in trouble
here is how we can transform a package from web pack to use alternative packages Fallbackhttps://webpack.js.org/configuration/resolve/#resolvefallback module.exports = {
// ...the rest of your config
resolve: {
fallback: {
stream: require.resolve('stream-browserify'),
}
}
} Aliasif its not work for you, you can alias the packages // webpack.config.js
module.exports = {
// ...the rest of your config
resolve: {
alias: {
'stream$': 'stream-browserify'
}
}
} @calvinmetcalf here is how you can export packages for browser, thank you for you amazing job <3 |
## Short description This PR adds a patch to `cipher-base` package to solve an "issue" during proximity verification flow. It could be related on how `io-app` do the bundle of sub-dependencies (like import/export issue). The patch is also related to these issues on other repositories: - https://stackoverflow.com/questions/74413490/uncaught-typeerror-cannot-read-properties-of-undefined-reading-call-at-hash - browserify/cipher-base#10 ## List of changes proposed in this pull request - Add patch file using patch-package ## How to test Static checks should be enough.
If your bundler is working properly, it will automatically shim node builtins. If it's broken by default, you may need to configure it to work properly. |
I am using angular 6 when i run ng serve
this error pops
ERROR in ./node_modules/cipher-base/index.js
Module not found: Error: Can't resolve 'stream' in '/home/devspot3/Sites/d-poll/node_modules/cipher-base'
ERROR in ./node_modules/hash-base/index.js
Module not found: Error: Can't resolve 'stream' in '/home/devspot3/Sites/d-poll/node_modules/hash-base'
The text was updated successfully, but these errors were encountered: