Skip to content

🐛 Cannot find module 'typescript' when run in commonjs #40

Description

@ansonchieng

Describe the bug

When attempting to run the project in CommonJS mode, an error occurs, stating that it cannot find the module typescript. This issue prevents the application from functioning as expected.

To Reproduce

  1. Create a new Node.js project and configure it to use CommonJS module system
  2. Install the "berryjam" package as a dependency for your project
  3. Copy the code from the README.md of the "berryjam" package. The code contains TypeScript-specific type and interface declarations, I removed them since I mentioned using CommonJS mode
  4. Execute the file to start the scanning process

Expected behavior

The application should be able to run in CommonJS mode without encountering this typescript module error.

Node Version

18.16.1

OS

No response

Browser

No response

Additional Context

Error Message:

Error: Cannot find module `typescript`
Require stack:
- ../node_modules/berryjam/lib/cjs/utils/compiler.js
- ../node_modules/berryjam/lib/cjs/vue-scanner.js
- ../node_modules/berryjam/lib/cjs/index.js
- ../main.cjs
    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Module._load (node:internal/modules/cjs/loader:920:27)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/Users/tong/Documents/node_modules/berryjam/lib/cjs/utils/compiler.js:35:25)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19) {

  code: 'MODULE_NOT_FOUND',

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPlaces where Berryjam is not working like how it is designed. Bug can be small or large in scope.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions