Fails to build in nodejs environment
See original GitHub issueHi! I’m trying to use this library with firebase functions (node 12 environment), but I’m getting a build error from tsc
.
It’s a newly create firebase functions project (so fairly standard settings). This is my tsconfig file:
{
"compilerOptions": {
"module": "commonjs",
"noImplicitReturns": true,
"noUnusedLocals": true,
"outDir": "lib",
"sourceMap": true,
"strict": true,
"target": "es2017",
"typeRoots": ["node_modules/@types"]
},
"compileOnSave": true,
"include": [
"src"
]
}
This is the output:
node_modules/@master-chief/alpaca/@types/stream.d.ts:1:23 - error TS2688: Cannot find type definition file for 'ws'.
1 /// <reference types="ws" />
~~
node_modules/@master-chief/alpaca/@types/stream.d.ts:2:8 - error TS1259: Module '"/Users/fredrik/github/garagefunds/functions/node_modules/isomorphic-ws/index"' can only be default-imported using the 'esModuleInterop' flag
2 import WebSocket from 'isomorphic-ws';
~~~~~~~~~
node_modules/isomorphic-ws/index.d.ts:8:1
8 export = WebSocket
~~~~~~~~~~~~~~~~~~
This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.
node_modules/@master-chief/alpaca/@types/stream.d.ts:3:8 - error TS1259: Module '"/Users/fredrik/github/garagefunds/functions/node_modules/eventemitter3/index"' can only be default-imported using the 'esModuleInterop' flag
3 import EventEmitter from 'eventemitter3';
~~~~~~~~~~~~
node_modules/eventemitter3/index.d.ts:134:1
134 export = EventEmitter;
~~~~~~~~~~~~~~~~~~~~~~
This module is declared with using 'export =', and can only be used with a default import when using the 'esModuleInterop' flag.
node_modules/isomorphic-ws/index.d.ts:6:28 - error TS7016: Could not find a declaration file for module 'ws'. '/Users/fredrik/github/garagefunds/functions/node_modules/ws/index.js' implicitly has an 'any' type.
Try `npm install @types/ws` if it exists or add a new declaration (.d.ts) file containing `declare module 'ws';`
6 import WebSocket = require('ws')
~~~~
Found 4 errors.
Any idea what this might be about?
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
Fails to build in nodejs environment · Issue #66
Hi! I'm trying to use this library with firebase functions (node 12 environment), but I'm getting a build error from tsc.
Read more >6 reasons your Node.js apps are failing
Can't figure out why your Node.js applications are failing? This article covers common Node failure points and the open source tools you can...
Read more >node.js build fails if warnings present
Hi Varnav, the build is failing as warnings are being treated as errors due to a certain environment variable being set/not set. In...
Read more >GYP ERR! build error. stack Error: 'make' failed with exit ...
I am currently working on a nodejs web application ...
Read more >15 Common Error Codes in Node.js and How to Fix Them
15. EPERM · Close all instances of your editor before rerunning the command (maybe some files were locked by the editor). · Clean...
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 FreeTop 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
Top GitHub Comments
@117 Doh, yeah installing ws types solved it! Should have tried it but I just assumed they were already included. Thanks!
@117 I don’t think there is something to fix on our side. I have a typescript project which works just fine. It has to be smth with the way project configured.
Here is a sample tsconfig, which works for me: