Comments (4)
I was able to solve the problem; to do this I had to add these polyfills. And installed the packages corresponding to these polyfills.
module.exports = {
webpack: {
configure: (config, { env, paths }) => {
const fallback = config.resolve.fallback || {};
Object.assign(fallback, {
assert: require.resolve("assert"),
buffer: require.resolve("buffer"),
console: require.resolve("console-browserify"),
constants: require.resolve("constants-browserify"),
crypto: require.resolve("crypto-browserify"),
domain: require.resolve("domain-browser"),
events: require.resolve("events"),
http: require.resolve("stream-http"),
https: require.resolve("https-browserify"),
os: require.resolve("os-browserify/browser"),
path: require.resolve("path-browserify"),
punycode: require.resolve("punycode"),
process: require.resolve("process/browser"),
querystring: require.resolve("querystring-es3"),
stream: require.resolve("stream-browserify"),
string_decoder: require.resolve("string_decoder"),
sys: require.resolve("util"),
timers: require.resolve("timers-browserify"),
tty: require.resolve("tty-browserify"),
url: require.resolve("url"),
util: require.resolve("util"),
vm: require.resolve("vm-browserify"),
zlib: require.resolve("./szlib"),
fs: false,
});
config.resolve.fallback = fallback;
config.plugins = (config.plugins || []).concat([]);
return config;
},
},
};
Pay attention to line zlib: require.resolve("./szlib"),
Content of file szlib.js
"use strict";
const bzlib = require("browserify-zlib");
const zlib = bzlib;
zlib.constants = zlib; //TODO select only constants
Object.assign(exports, zlib);
without this we will have an error
ERROR
Cannot read properties of undefined (reading 'Z_SYNC_FLUSH')
TypeError: Cannot read properties of undefined (reading 'Z_SYNC_FLUSH')
at ./node_modules/@microsoft/iot-cardboard-js/internal/axios-1bc8e67b.js (http://localhost:3000/static/js/bundle.js:666676:67)
at options.factory (http://localhost:3000/static/js/bundle.js:880420:31)
at __webpack_require__ (http://localhost:3000/static/js/bundle.js:879813:33)
at fn (http://localhost:3000/static/js/bundle.js:880077:21)
at ./node_modules/@microsoft/iot-cardboard-js/internal/HierarchyNode-05d12d93.js (http://localhost:3000/static/js/bundle.js:63903:76)
at options.factory (http://localhost:3000/static/js/bundle.js:880420:31)
at __webpack_require__ (http://localhost:3000/static/js/bundle.js:879813:33)
at fn (http://localhost:3000/static/js/bundle.js:880077:21)
at ./node_modules/@microsoft/iot-cardboard-js/internal/ADT3DSceneAdapter-0423f1cf.js (http://localhost:3000/static/js/bundle.js:16630:84)
at options.factory (http://localhost:3000/static/js/bundle.js:880420:31)
from iot-cardboard-js.
I downgraded the version with npm install @microsoft/[email protected]
and it worked
from iot-cardboard-js.
@K1vs Thanks for recommending the corresponding polyfills. It resolved the dependency errors to a great extent, but I found one more error on my terminal, when using this as a template in my React app.
I am using node v16.
Module not found: Error: Can't resolve 'process/browser' in 'C:\Users\0007CI744\Documents\Projects\cardboard-demo\node_modules@headlessui\react\dist\components\combobox'
Did you mean 'browser.js'?
For anyone else facing this, please note I had to make the below additions to my config-overrides.js
config.module.rules.unshift({ test: /\.m?js$/, resolve: { fullySpecified: false, // disable the behavior }, });
and to the fallback object, I added
"process/browser": require.resolve("process/browser"),
from iot-cardboard-js.
After successful code compilation, I am getting this error on my browser. Any idea, how to fix this?
Uncaught TypeError: util__WEBPACK_IMPORTED_MODULE_0__.TextEncoder is not a constructor
from iot-cardboard-js.
Related Issues (20)
- Console warning HOT 2
- AGPL3 violation HOT 2
- Configure environment button does not open Environment picker
- Cannot pull modelled properties on new form in behavior
- CORS error on babylon wasm assembly
- DOM validation warning message
- Possibility to use access token HOT 1
- Support string fields in Simple Data History Widget HOT 1
- A11y issue: Kraken theme error message text color is not accessible HOT 1
- msal-react package integration
- Status Update - Rena Liu HOT 2
- Status Update - Peyton Fraser
- Pause & Play particular Model Animation Based on the condition HOT 5
- Displaying the Dynamic text on the 3D models HOT 1
- Client credential flow for 3d scene viewer
- Unable to Install & Run this package in angular app
- Unable to deploy application on Azure Web App
- Unable to upload DT to React APP
- Update npm package to webpack 5 compatible
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from iot-cardboard-js.