cant access azure/storage-blob from nodejs app

Deepakkumar Subramaniam 0 Reputation points
2024-05-14T19:58:15.99+00:00

Cant access the @azure/storage-blob. I mean getting undefined when I try to access the BlobServiceClient in the node js app.
const {BlobServiceClient} = require("@azure/storage-blob");

Using azure/storage-blob version "12.4.0", and my node version is v13.8.0.

Previously it was working fine, suddenly stopped working and throwing this error randomly.

Error: Cannot find module 'node:os'

Require stack:

  • /app/node_modules/@azure/logger/dist/commonjs/log.js
  • /app/node_modules/@azure/logger/dist/commonjs/debug.js
  • /app/node_modules/@azure/logger/dist/commonjs/index.js
  • /app/node_modules/@azure/core-http/dist/index.js
  • /app/node_modules/@azure/storage-blob/dist/index.js

Any help would be appreciated. Thank you

Azure Storage Explorer
Azure Storage Explorer
An Azure tool that is used to manage cloud storage resources on Windows, macOS, and Linux.
266 questions
Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
2,921 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
995 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anand Prakash Yadav 7,795 Reputation points Microsoft Vendor
    2024-05-15T11:39:40.3066667+00:00

    Hello Deepakkumar Subramaniam,

    Thank you for posting your query here!

    It looks like you’re encountering an issue with the @azure/storage-blob package in your Node.js app. The error message you’re seeing, “Cannot find module ‘node:os’”, suggests that there might be a problem with the Node.js environment or the way dependencies are being resolved.

    · You might want to consider upgrading to a more recent Node.js LTS version to see if that resolves the issue.

    · Sometimes, dependencies can become corrupted or mismatched. Try removing the node_modules folder and reinstalling your dependencies:
    rm -rf node_modules
    npm install
    After reinstalling, check if the issue persists.

    · Also, review your project's dependencies and ensure that there are no conflicts or outdated packages that could be causing compatibility issues. And cross check your network connection and firewall settings to make sure they allow the app to communicate with the Azure Blob Storage service.

    Do let us know if you have any further queries. I’m happy to assist you further.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.