angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.76k stars 11.97k forks source link

mysterious node.js runtime error #17781

Closed wcjord closed 4 years ago

wcjord commented 4 years ago

In the current npm package, @angular-devkit/build-angular v 0.901.7, the package "less" is a dependency. In the github repo, less is not a dependency. This package contains the deprecated request package which breaks in a Typescript 3.8 project, supported by Angular 9.1.

To reproduce issue;

  1. Create a new angular 9 project.
  2. Remove node_modules
  3. npm install
  4. Request is now present in project and will break with typescript 3.8.
alan-agius4 commented 4 years ago

Hi @wcjord,

I am sorry but we are not understanding the problem you are reporting here.

In the current npm package, @angular-devkit/build-angular v 0.901.7, the package "less" is a dependency. In the github repo, less is not a dependency.

Less is a direct dependency of @angular-devkit/build-angular https://github.com/angular/angular-cli/blob/ebd5cbc81b80393d1afda896a1dc9623721ff790/packages/angular_devkit/build_angular/package.json#L36

This package contains the deprecated request package which breaks in a Typescript 3.8 project, supported by Angular 9.1.

Why does the request, package break TypeScript?

wcjord commented 4 years ago

Hi @alan-agius4,

Thanks so much for the quick reply. The specific error on ng serve is:

Module not found: Error: Can't resolve 'zlib' in '/node_modules/request'

Npm ls request:

├─┬ @angular-devkit/build-angular@0.901.6
│ └─┬ less@3.11.1
│   └── request@2.88.2 
├─┬ @angular/cli@9.1.6
│ └─┬ universal-analytics@0.4.20
│   └── request@2.88.2  deduped

I followed the github repo link on the @angular-devkit/build-angular npm page which took me here to what looks to be the master branch of the angular-cli and a navigated to the package.json of @angular-devkit/build-angular.

https://github.com/angular/angular-cli/blob/a42ce844a7b706bbfc8222ddcad178e4453db0be/packages/angular_devkit/build_angular/package.json#L36-L40

It's not listed there and that makes sense. Less seems to work with Typescript 3.7 but breaks with Typescript 3.8 and the Angular 9.1 update introduced Typescript 3.8 support.

It seems that the branch you referenced is what's currently live on npm and the current master needs an npm publish.

alan-agius4 commented 4 years ago

@wcjord, the current master branch is targeting Angular CLI 10.1

Since version 10, less is no longer a direct dependency because it’s now a transitive dependency via less-loader #17546

It's not listed there and that makes sense. Less seems to work with Typescript 3.7 but breaks with Typescript 3.8 and the Angular 9.1 update introduced Typescript 3.8 support.

Are you referring to the above mentioned error? That error, is not caused by TypeScript but rather a node.js runtime error.

Can you try the following:

wcjord commented 4 years ago

Hey @alan-agius4,

I'm now unable to reproduce the error in a new project. I've been trying a few things so like a global reinstall of the angular cli.

I'm still trying to get the existing but upgraded 8 -> 9.1 project working. I've tried this sequence,

rm -rf node_modules package-lock.json npm install

a few times now. I'll give it another shot though. Here are some more of the error logs:


WARNING in ./node_modules/bcrypt/bcrypt.js 6:15-36
Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/node-pre-gyp/lib/pre-binding.js 20:22-48
Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/node-pre-gyp/lib/util/versioning.js 17:20-67
Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/node-pre-gyp/lib/util/compile.js
Module not found: Error: Can't resolve 'node-gyp' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib/util'

WARNING in ./node_modules/node-pre-gyp/lib/util/compile.js
Module not found: Error: Can't resolve 'npm' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib/util'

WARNING in ./node_modules/needle/node_modules/sax/lib/sax.js
Module not found: Error: Can't resolve 'stream' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/needle/node_modules/sax/lib'

WARNING in ./node_modules/needle/lib/needle.js
Module not found: Error: Can't resolve 'zlib' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/needle/lib'

WARNING in ./node_modules/node-pre-gyp/lib/util/nw-pre-gyp/index.html 1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> <!doctype html>
| <html>
| <head>

ERROR in ./src/app/components/chat-progress/pan-counter/pan-counter.component.ts 100:27-42
"export 'duration' (imported as 'moment') was not found in 'ngx-moment'
ERROR in ./node_modules/node-pre-gyp/lib/unpublish.js
Module not found: Error: Can't resolve 'aws-sdk' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib'
ERROR in ./node_modules/node-pre-gyp/lib/publish.js
Module not found: Error: Can't resolve 'aws-sdk' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib'
ERROR in ./node_modules/node-pre-gyp/lib/info.js
Module not found: Error: Can't resolve 'aws-sdk' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib'
ERROR in ./node_modules/detect-libc/lib/detect-libc.js
Module not found: Error: Can't resolve 'child_process' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/detect-libc/lib'
ERROR in ./node_modules/node-pre-gyp/lib/testbinary.js
Module not found: Error: Can't resolve 'child_process' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib'
ERROR in ./node_modules/node-pre-gyp/lib/util/compile.js
Module not found: Error: Can't resolve 'child_process' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib/util'
ERROR in ./node_modules/osenv/osenv.js
Module not found: Error: Can't resolve 'child_process' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/osenv'
ERROR in ./node_modules/aws-sign2/index.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/aws-sign2'
ERROR in ./node_modules/aws4/aws4.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/aws4'
ERROR in ./node_modules/bcrypt/bcrypt.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/bcrypt'
ERROR in ./node_modules/ecc-jsbn/index.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/ecc-jsbn'
ERROR in ./node_modules/http-signature/lib/signer.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/http-signature/lib'
ERROR in ./node_modules/http-signature/lib/verify.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/http-signature/lib'
ERROR in ./node_modules/needle/lib/auth.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/needle/lib'
ERROR in ./node_modules/oauth-sign/index.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/oauth-sign'
ERROR in ./node_modules/request/lib/hawk.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/request/lib'
ERROR in ./node_modules/request/lib/oauth.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/request/lib'
ERROR in ./node_modules/request/lib/helpers.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/request/lib'
ERROR in ./node_modules/sshpk/lib/dhe.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/sshpk/lib'
ERROR in ./node_modules/sshpk/lib/identity.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/sshpk/lib'
mERROR in ./node_modules/sshpk/lib/certificate.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/sshpk/lib'
ERROR in ./node_modules/sshpk/lib/private-key.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/sshpk/lib'
ERROR in ./node_modules/sshpk/lib/signature.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/sshpk/lib'
ERROR in ./node_modules/sshpk/lib/key.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/sshpk/lib'
ERROR in ./node_modules/sshpk/lib/fingerprint.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/sshpk/lib'
ERROR in ./node_modules/sshpk/lib/utils.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/sshpk/lib'
ERROR in ./node_modules/sshpk/lib/formats/pem.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/sshpk/lib/formats'
ERROR in ./node_modules/sshpk/lib/formats/openssh-cert.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/sshpk/lib/formats'
ERROR in ./node_modules/sshpk/lib/formats/ssh-private.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/sshpk/lib/formats'
ERROR in ./node_modules/tar/lib/unpack.js
Module not found: Error: Can't resolve 'crypto' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/tar/lib'
ERROR in ./node_modules/chownr/chownr.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/chownr'
ERROR in ./node_modules/detect-libc/lib/detect-libc.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/detect-libc/lib'
ERROR in ./node_modules/fs-minipass/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/fs-minipass'
ERROR in ./node_modules/fs.realpath/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/fs.realpath'
ERROR in ./node_modules/fs.realpath/old.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/fs.realpath'
ERROR in ./node_modules/glob/glob.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/glob'
ERROR in ./node_modules/glob/sync.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/glob'
ERROR in ./node_modules/ignore-walk/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/ignore-walk'
ERROR in ./node_modules/mkdirp/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/mkdirp'
ERROR in ./node_modules/needle/lib/needle.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/needle/lib'
ERROR in ./node_modules/needle/lib/multipart.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/needle/lib'
ERROR in ./node_modules/node-pre-gyp/lib/testpackage.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib'
ERROR in ./node_modules/node-pre-gyp/lib/install.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib'
ERROR in ./node_modules/node-pre-gyp/lib/unpublish.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib'
ERROR in ./node_modules/node-pre-gyp/lib/reinstall.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib'
ERROR in ./node_modules/node-pre-gyp/lib/rebuild.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib'
ERROR in ./node_modules/node-pre-gyp/lib/info.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib'
ERROR in ./node_modules/node-pre-gyp/lib/publish.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib'
ERROR in ./node_modules/node-pre-gyp/lib/pre-binding.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib'
ERROR in ./node_modules/node-pre-gyp/lib/package.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib'
ERROR in ./node_modules/node-pre-gyp/lib/node-pre-gyp.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib'
ERROR in ./node_modules/node-pre-gyp/lib/clean.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib'[22m
ERROR in ./node_modules/node-pre-gyp/lib/reveal.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib'
ERROR in ./node_modules/node-pre-gyp/lib/testbinary.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib'
ERROR in ./node_modules/node-pre-gyp/lib/util/napi.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib/util'
ERROR in ./node_modules/node-pre-gyp/lib/util/compile.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib/util'
ERROR in ./node_modules/node-pre-gyp/lib/util/handle_gyp_opts.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/node-pre-gyp/lib/util'
ERROR in ./node_modules/npm-bundled/index.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/npm-bundled'
ERROR in ./node_modules/request/lib/har.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/request/lib'
ERROR in ./node_modules/rimraf/rimraf.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/rimraf'
ERROR in ./node_modules/tar/lib/write-entry.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/tar/lib'
ERROR in ./node_modules/tar/lib/mkdir.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/tar/lib'
ERROR in ./node_modules/tar/lib/unpack.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/tar/lib'
ERROR in ./node_modules/tar/lib/list.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/tar/lib'
ERROR in ./node_modules/tar/lib/replace.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/tar/lib'
ERROR in ./node_modules/tar/lib/create.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/tar/lib'
ERROR in ./node_modules/tar/lib/extract.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/tar/lib'
ERROR in ./node_modules/tar/lib/pack.js
Module not found: Error: Can't resolve 'fs' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/tar/lib'
ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can't resolve 'http' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/forever-agent'
ERROR in ./node_modules/http-signature/lib/signer.js
Module not found: Error: Can't resolve 'http' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/http-signature/lib'
ERROR in ./node_modules/needle/lib/needle.js
Module not found: Error: Can't resolve 'http' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/needle/lib'
ERROR in ./node_modules/request/request.js
Module not found: Error: Can't resolve 'http' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/request'
ERROR in ./node_modules/tunnel-agent/index.js
Module not found: Error: Can't resolve 'http' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/tunnel-agent'
ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can't resolve 'https' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/forever-agent'
ERROR in ./node_modules/needle/lib/needle.js
Module not found: Error: Can't resolve 'https' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/needle/lib'
ERROR in ./node_modules/request/request.js
Module not found: Error: Can't resolve 'https' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/request'
ERROR in ./node_modules/tunnel-agent/index.js
Module not found: Error: Can't resolve 'https' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/tunnel-agent'
ERROR in ./src/app/tab.topics/topics.page.ts
Module not found: Error: Can't resolve 'marked' in '/Users/willjc/Documents/PangeaChat/pangeav4/src/app/tab.topics'
ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can't resolve 'net' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/forever-agent'
ERROR in ./node_modules/tough-cookie/lib/cookie.js
Module not found: Error: Can't resolve 'net' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/tough-cookie/lib'
ERROR in ./node_modules/tunnel-agent/index.js
Module not found: Error: Can't resolve 'net' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/tunnel-agent'
ERROR in ./node_modules/detect-libc/lib/detect-libc.js
Module not found: Error: Can't resolve 'os' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/detect-libc/lib'
ERROR in ./node_modules/has-unicode/index.js
Module not found: Error: Can't resolve 'os' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/has-unicode'
ERROR in ./node_modules/os-homedir/index.js
Module not found: Error: Can't resolve 'os' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/os-homedir'
ERROR in ./node_modules/assert-plus/assert.js
Module not found: Error: Can't resolve 'stream' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/assert-plus'
ERROR in ./node_modules/combined-stream/lib/combined_stream.js
Module not found: Error: Can't resolve 'stream' in '/Users/willjc/Documents/PangeaChat/pangeav4/node_modules/combined-stream/lib'

And the version info:

Angular CLI: 9.1.7
Node: 10.20.1
OS: darwin x64

Angular: 9.1.9
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router, service-worker
Ivy Workspace: Yes

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.901.7
@angular-devkit/build-angular     0.901.7
@angular-devkit/build-optimizer   0.901.7
@angular-devkit/build-webpack     0.901.7
@angular-devkit/core              9.1.7
@angular-devkit/schematics        9.1.7
@angular/cdk                      9.2.4
@angular/cli                      9.1.7
@angular/fire                     6.0.0
@angular/material                 9.2.4
@ngtools/webpack                  9.1.7
@schematics/angular               9.1.7
@schematics/update                0.901.7
rxjs                              6.5.5
typescript                        3.8.3
webpack                           4.42.0

Thanks again for your attention to this

alan-agius4 commented 4 years ago

Are you using default angular cli builders?

I am seeing a lot of modules which shouldn’t be included in the compilation like fs for example.

clydin commented 4 years ago

Most likely cause of those errors is an accidental import of a non-web related package.

wcjord commented 4 years ago

We're using Angular9 with Ionic 5. I made a new Ionic 5 project and started gradually adding dependencies back in. It didn't break until I added src. So something on our end is screwed up. It's till a mystery what it is.

The very strange part to me is that, for a module like "sshpk" which was one of the modules not found and in the list of errors above. The only consumer is the @angular-devkit/build-angular.

└─┬ @angular-devkit/build-angular@0.901.7
  └─┬ less@3.11.1
    └─┬ request@2.88.2
      └─┬ http-signature@1.2.0
        └── sshpk@1.16.1 

I don't understand why the contents of src would even make a difference on that.

alan-agius4 commented 4 years ago

As @clydin mentioned, In your src you might be importing a non web package which use node.js utils and libraries.

wcjord commented 4 years ago

That is indeed what is happening.

The situation is that I've made an npm package where I define all of the document types for our mongo database. This package includes mongoose and a typescript add-on to that called typegoose. What's very helpful about this is that the interfaces are defined once and shared by the client and server.

What I didn't realize was, exactly what you've pointed me to, that the package (typegoose/mongoose) are using some pieces of node.js.

The only thing that the client needs from this package is the type definitions. Is there a way to include just those in the compile and exclude everything else?

alan-agius4 commented 4 years ago

@wcjord, if it's solely typings the above issue shouldn't happen because imports used only as types reference are elided during compilation.

Potentially, you could also get around this by using the new TS 3.8 feature Type-Only Imports and Export more info here: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html

I am going to close this, as it seems that it's not a bug in Angular CLI.

wcjord commented 4 years ago

@alan-agius4 There are also some pure functions and constants imported into the client but nothing using the libraries that are breaking things. Can you point me to some documentation about "imports used only as types reference are elided during compilation?" Thank you for your time on this.

alan-agius4 commented 4 years ago

There are also some pure functions and constants imported into the client but nothing using the libraries that are breaking things

In that case, probable you'll need to split the shared library even more.

Can you point me to some documentation about "imports used only as types reference are elided during compilation?" Thank you for your time on this.

https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-8.html#type-only-imports-and-export

angular-automatic-lock-bot[bot] commented 4 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.