tslib not found in node server production build
See original GitHub issuePrerequisites
Please answer the following questions for yourself before submitting an issue. YOU MAY DELETE THE PREREQUISITES SECTION.
- I am running the latest version
- I checked the documentation (nx.dev) and found no answer
- I checked to make sure that this issue has not already been filed
- I’m reporting the issue to the correct repository (not related to React, Angular or any dependency)
Expected Behavior
I build a production build of my node app, which is generated from @nrwl/node
, calling nx build api --prod
. I copy the generated files onto my server (or just another directory) and start it with node main.js
.
Current Behavior
The error I get when starting is:
> node main.js
internal/modules/cjs/loader.js:800
throw err;
^
Error: Cannot find module 'tslib'
Require stack:
- C:\Users\vinca\Desktop\main.js
[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)[39m
[90m at Function.Module._load (internal/modules/cjs/loader.js:690:27)[39m
[90m at Module.require (internal/modules/cjs/loader.js:852:19)[39m
[90m at require (internal/modules/cjs/helpers.js:74:18)[39m
at Object.<anonymous> (C:\Users\vinca\Desktop\main.js:91:18)
at __webpack_require__ (C:\Users\vinca\Desktop\main.js:20:30)
at Object.<anonymous> (C:\Users\vinca\Desktop\main.js:1086:17)
at __webpack_require__ (C:\Users\vinca\Desktop\main.js:20:30)
at Object.<anonymous> (C:\Users\vinca\Desktop\main.js:1076:18)
at __webpack_require__ (C:\Users\vinca\Desktop\main.js:20:30) {
code: [32m'MODULE_NOT_FOUND'[39m,
requireStack: [ [32m'C:\\Users\\vinca\\Desktop\\main.js'[39m ]
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top Results From Across the Web
Cannot find module 'tslib' while dockerizing an Adonis app v5
Run the following command to create a production build. ... build folder to your production server, install the dependencies and run node ......
Read more >tslib - npm
tslib. This is a runtime library for TypeScript that contains all of the TypeScript helper functions. This library is primarily used by the ......
Read more >This syntax requires an imported helper but module 'tslib ...
To solve the error "This syntax requires an imported helper but module 'tslib' cannot be found", install tslib by running npm install -D...
Read more >TypeScript for Node.js - Sentry Documentation
First, make sure that tslib is listed as the dependency in your package.json file. Once that's done, add two entries in compilerOptions section...
Read more >TypeScript: JavaScript With Syntax For Types.
TypeScript is a strongly typed programming language that builds on ... which runs anywhere JavaScript runs: In a browser, on Node.js or Deno...
Read more >
Top Related Medium Post
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
For people who are trying out
nx
and ended up here from google.You probably have set
"importHelpers": true
(default config) in yourtsconfig.base.json
which will usetslib
package when there’s a need to emit helpers in generated code.There are reasons when such behavior is Preferred but if you want to opt out of it you could set that flag to
false
.References
I added this flag in production build config:
"externalDependencies": "none"