Error: Cannot find module 'ts-tiny-invariant'
See original GitHub issueI just upgraded to apollo-server-core
: 3.0.1. When I deploy my code to AWS Lambda with ESBuild I get the following error
Error: Cannot find module 'ts-tiny-invariant'
Require stack:
- /var/task/index.js
- /var/runtime/UserFunction.js
- /var/runtime/index.js
I am creating a new server with apollo-server-express
I’m not 100% sure but this might be caused by ts-is-defined
being compiled with Typescript 3.x https://github.com/iyegoroff/ts-is-defined/blob/master/package.json#L40
The compiled code after ESBuild is the following for ts-is-defined
// node_modules/ts-is-defined/dist/umd/index.js
var require_umd2 = __commonJS({
"node_modules/ts-is-defined/dist/umd/index.js"(exports2, module2) {
var __importDefault = exports2 && exports2.__importDefault || function(mod) {
return mod && mod.__esModule ? mod : { "default": mod };
};
(function(factory) {
if (typeof module2 === "object" && typeof module2.exports === "object") {
var v = factory(require, exports2);
if (v !== void 0)
module2.exports = v;
} else if (typeof define === "function" && define.amd) {
define(["require", "exports", "ts-tiny-invariant"], factory);
}
})(function(require2, exports3) {
"use strict";
Object.defineProperty(exports3, "__esModule", { value: true });
exports3.assertIsDefined = exports3.isDefined = void 0;
var ts_tiny_invariant_1 = __importDefault(require2("ts-tiny-invariant"));
function isDefined(value) {
return value !== void 0 && value !== null;
}
exports3.isDefined = isDefined;
function assertIsDefined(value, message) {
ts_tiny_invariant_1.default(isDefined(value), message);
}
exports3.assertIsDefined = assertIsDefined;
});
}
});
And here is ts-tiny-invariant
defined in the same file
// node_modules/ts-tiny-invariant/dist/umd/index.js
var require_umd = __commonJS({
"node_modules/ts-tiny-invariant/dist/umd/index.js"(exports2, module2) {
(function(factory) {
if (typeof module2 === "object" && typeof module2.exports === "object") {
var v = factory(require, exports2);
if (v !== void 0)
module2.exports = v;
} else if (typeof define === "function" && define.amd) {
define(["require", "exports"], factory);
}
})(function(require2, exports3) {
"use strict";
Object.defineProperty(exports3, "__esModule", { value: true });
var isProduction = process.env.NODE_ENV === "production";
var prefix = "Invariant failed";
function invariant(condition, message) {
if (condition) {
return;
}
throw new Error(isProduction ? prefix : prefix + ": " + (message || ""));
}
exports3.default = invariant;
});
}
});
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
ts-tiny-invariant - npm
ts -tiny-invariant. TypeScript icon, indicating that this package has built-in type declarations. 2.0.4 • Public • Published 7 months ago.
Read more >Missing npm dependency in serverless function (with yarn)
Certain npm dependencies are missing in my Vercel function deployment ... "stack": [ "Error: Cannot find module 'ts-tiny-invariant'", ...
Read more >Chris Watts on Twitter: "Error: Cannot find module 'ts-tiny-invariant ...
I just upgraded to apollo-server-core: 3.0.1. When I deploy my code to AWS Lambda with ESBuild I get the following error Error: Cannot...
Read more >Getting 'invarient' not found error on creating a react native ...
After some search I found this answer from ErmannoS: npm i --save-dev invariant . But I decided to try install invariant globally npm...
Read more >module-not-found - Next.js
A module not found error can occur for many different reasons: The module you're trying to import is not installed in your dependencies....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I removed the
ts-is-defined
dependency from@graphql-tools/mock
and the most recent patch of@graphql-tools/mock
has the fix applied.apollo-server
pulled the patch in #5552 so it should be fixed in the next release.I manually patched my lockfile and confirmed that the fix works in a lambda environment.
Hey @glasser we are having the same issue by using “Serverless-stack: https://serverless-stack.com”, it uses esbuild under the hood.
The Apollo Server runs fine locally but on AWS Lambda the built version crashes with this error too:
Is it possible to reopen this issue?