Azure / azure-iot-sdk-node

A Node.js SDK for connecting devices to Microsoft Azure IoT services
https://docs.microsoft.com/en-us/azure/iot-hub/
Other
261 stars 226 forks source link

Unable to resolve crypto #1220

Closed Shahanshah-TA closed 3 months ago

Shahanshah-TA commented 3 months ago

Installed packages "azure-iot-provisioning-device": "^1.9.1", "azure-iot-provisioning-device-mqtt": "^1.8.1", "azure-iot-security-symmetric-key": "^1.8.2",

Error: Unable to resolve module crypto from /node_modules/azure-iot-common/dist/authorization.js: crypto could not be found within the project or in these directories: node_modules ../node_modules 5 | Object.defineProperty(exports, "__esModule", { value: true }); 6 | exports.hmacHash = exports.stringToSign = exports.encodeUriComponentStrict = exports.anHourFromNow = void 0;

7 | const crypto = require("crypto");

Using in react native bare project.

shims.js import 'react-native-url-polyfill/auto'; import 'react-native-get-random-values'; import 'text-encoding-polyfill'; const getRandomValues = global.crypto.getRandomValues; import * as crypto from 'isomorphic-webcrypto'; global.crypto = crypto; global.crypto.getRandomValues = getRandomValues;