Skip to content

Cannot find module 'tslib' - tslib has become an indirect dependency #29

@kidroca

Description

@kidroca

Package version

v5.0.9

Node.js and npm version

  • node: v14.15.1
  • npm: v6.14.8

Issue

tslib has become an indirect dependency due to the ts compiler option "importHelpers": true used here: 5e73968#diff-b55cdbef4907b7045f32cc5360d48d262cca5f94062e353089f189f4460039e0R6

Importing the transpiled code requires for the "importer" to have installed tslib (dependency)

Example: node_modules/@adonisjs/redis/build/src/RedisConnection/index.js

"use strict";
/*
 * @adonisjs/redis
 *
 * (c) Harminder Virk <virk@adonisjs.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.RedisConnection = void 0;
const tslib_1 = require("tslib");

Users now get the following exception when starting the production server:

Error: Cannot find module 'tslib'
Require stack:
- /app/node_modules/@adonisjs/redis/build/src/RedisConnection/index.js
- /app/node_modules/@adonisjs/redis/build/src/RedisManager/index.js
- /app/node_modules/@adonisjs/redis/build/providers/RedisProvider.js
- /app/node_modules/@poppinss/utils/build/src/esmRequire.js
- /app/node_modules/@poppinss/utils/build/index.js
- /app/node_modules/@adonisjs/fold/build/src/Ioc/index.js
- /app/node_modules/@adonisjs/fold/build/index.js
- /app/node_modules/@adonisjs/application/build/index.js
- /app/node_modules/@adonisjs/core/build/standalone.js
- /app/server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/app/node_modules/@adonisjs/redis/build/src/RedisConnection/index.js:12:17)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)

Reproducing

Create a hello-world template project and add redis following the redis guide
Then:

  • npm run build
  • cp -r ./build ../../somewhere/soThatParentNodeModulesIsNotUsed
  • cd
  • npm ci --production
  • node server.js

Sample Repository

https://github.com/kidroca/adonis-redis-tslib-error-sample

Metadata

Metadata

Assignees

Labels

Type: BugThe issue has indentified a bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions