question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TS2305: Module '"[...]node_modules/@improbable-eng/grpc-web/dist/grpc-web-client.umd"' has no exported member 'grpc'.

See original GitHub issue

This is probably a mistake my side, and it’s 4pm Friday so we’ll see if I can fix it after the beers make an appearance - but I thought I’d make a cry for help also!

package.json

"dependencies": {
    "@improbable-eng/grpc-web": "0.9.1",
    "@types/google-protobuf": "^3.2.5",
    "google-protobuf": "^3.2.0",

service / request user.ts file import {grpc} from "@improbable-eng/grpc-web";

Full browser log

./src/services/user.ts
Module build failed (from ./node_modules/ts-loader/index.js):
Error: Typescript emitted no output for [...]src/services/user.ts.
    at successLoader ([...]node_modules/ts-loader/dist/index.js:41:15)
    at Object.loader ([...]node_modules/ts-loader/dist/index.js:21:12)
console.(anonymous function) @ console.js?00ac:35
errors @ client?81da:168
onmessage @ socket.js?e29c:41
EventTarget.dispatchEvent @ sockjs.js?9be2:170
(anonymous) @ sockjs.js?9be2:887
SockJS._transportMessage @ sockjs.js?9be2:885
EventEmitter.emit @ sockjs.js?9be2:86
WebSocketTransport.ws.onmessage @ sockjs.js?9be2:2961
console.js?00ac:35 [...]src/services/user.ts
./src/services/user.ts
[tsl] ERROR in [...]src/services/user.ts(1,9)
      TS2305: Module '"[...]node_modules/@improbable-eng/grpc-web/dist/grpc-web-client.umd"' has no exported member 'grpc'.

Module import folder

[ '|-- node_modules',
  '    |-- grpc-web',
  '        |-- LICENSE.txt',
  '        |-- README.md',
  '        |-- package.json',
  '        |-- dist',
  '            |-- grpc-web-client.js',
  '            |-- grpc-web-client.umd.js',
  '            |-- typings',
  '                |-- ChunkParser.d.ts',
  '                |-- Code.d.ts',
  '                |-- client.d.ts',
  '                |-- debug.d.ts',
  '                |-- detach.d.ts',
  '                |-- index.d.ts',
  '                |-- invoke.d.ts',
  '                |-- message.d.ts',
  '                |-- metadata.d.ts',
  '                |-- service.d.ts',
  '                |-- unary.d.ts',
  '                |-- util.d.ts',
  '                |-- transports',
  '                    |-- Transport.d.ts',
  '                    |-- http',
  '                    |   |-- fetch.d.ts',
  '                    |   |-- http.d.ts',
  '                    |   |-- xhr.d.ts',
  '                    |   |-- xhrUtil.d.ts',
  '                    |-- websocket',
  '                        |-- websocket.d.ts',
  '' ]
  • Vue app
  • Yarn not npm

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:25 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
awmichelcommented, Dec 2, 2019

I ran into this working on https://github.com/Dig-Doug/rules_typescript_proto/pull/13 as well. It looks like the examples use a ES module syntax import { grpc } from '@improbable-eng/grpc-web;`, but Webpack is generating a CommonJS export.

https://github.com/improbable-eng/grpc-web/blob/721eb32e2c2fef541a6cdd6e2e92e73b7471b861/client/grpc-web/webpack.config.js#L25

I believe historically tools like Webpack/Rollup gracefully handled this, however lately it seems more and more are refusing the transparently convert between CommonJS/ESM formats.

Configuring Webpack to generate a ESM lib and adding "module": "dist/grpc-web-client.mjs", to the package.json should do the trick. It’s also possible generating a .mjs version alone will work, but adding the module declaration to the package file can’t hurt.

References: ES Module Reference Hybrid NPM Packages Blog Post

2reactions
graupcommented, Jul 16, 2019

I have a similar issue with rollup. I had to define a namedExport to make this work withrollup-plugin-commonjs, otherwise it throws the same error as in the OP. This is for a browser (umd) build.

Something like

commonjs({
    namedExports: {'path/to/node_modules/@improbable-eng/grpc-web/dist/grpc-web-client.umd.js': ['grpc']}
}),
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to solve the "module has no exported member" error?
Remove the line below from your statement export module Demo. and use it like export class ViewModel { constructor(public test: string) { }...
Read more >
Module '"@prismicio/client"' has no exported member 'Content'
As title states, I'm getting this error: This is my prismic.ts: import * as prismic from '@prismicio/client'; import * as prismicNext from ...
Read more >
[Pro User] No exported member - Material Design for Bootstrap
Hi, I on index.ts file, under node_modules/ng-mdb-pro, the error below Error:(2, 9) TS2305: Module '../node_modules/ng-mdb-pro/free/index' has no exported ...
Read more >
Unable to resolve "@pnp/graph"' has no exported member ...
Now, while using 'import { graph } from "@pnp/graph"' I am getting below error. '"@pnp/graph"' has no exported member named 'graph'. Please ...
Read more >
module '"@angular/core"' has no exported member 'ngmodule'
[0] app/app.module.ts(3,10): error TS2305: Module '"/user/blah-blah/angular/node_modules/@angular/router/index ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found