Skip to content

support of pnpm when installing a new app #13680

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
kkoo95 opened this issue Feb 14, 2019 · 4 comments · Fixed by #15051
Closed

support of pnpm when installing a new app #13680

kkoo95 opened this issue Feb 14, 2019 · 4 comments · Fixed by #15051

Comments

@kkoo95
Copy link

kkoo95 commented Feb 14, 2019

🚀 Feature request

Command

- [x] new
- [x] build
- [x] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Description

a new app or library generated with CLI 7.3.1 but installed with pnpm doesn't compile.

$ ng new test-pnpm --skip-install
$ cd test-pnpm
$ pnpm i
$ ng serve

result:

** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **

Date: 2019-02-14T21:12:54.636Z
Hash: e8745ed29e7097ee7e23
Time: 15155ms
chunk {es2015-polyfills} es2015-polyfills.js, es2015-polyfills.js.map (es2015-polyfills) 368 kB [initial] [rendered]
chunk {main} main.js, main.js.map (main) 9.35 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 262 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 6.08 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 514 bytes [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 3.56 MB [initial] [rendered]

ERROR in (webpack)/hot/emitter.js
Module not found: Error: Can't resolve 'events' in 'D:\dev\clones\test-pnpm\node_modules\.registry.npmjs.org\webpack\4.29.0\webpack@                                                  4.29.0\node_modules\webpack\hot'
ERROR in ./src/app/app.component.ts
Module not found: Error: Can't resolve 'postcss-loader' in 'D:\dev\clones\test-pnpm'
ERROR in ./src/app/app.component.ts
Module not found: Error: Can't resolve 'raw-loader' in 'D:\dev\clones\test-pnpm'
ERROR in multi ./src/styles.css
Module not found: Error: Can't resolve 'style-loader' in 'D:\dev\clones\test-pnpm'
i 「wdm」: Failed to compile.

From what i read, it would have to do with how angular is declaring its dependencies in the generated package.json.

Describe alternatives you've considered

There is a workaround within pnpm. One can use the shamefully-flatten install flag so that node_modules are laid out like yarn or npm. But it is a shame to have to do that right ? :).
But this workaround only works for angular application (serve and build), not libraries

@alan-agius4 alan-agius4 added freq1: low Only reported by a handful of users who observe it rarely severity3: broken area: @angular/cli labels Feb 15, 2019
@ngbot ngbot bot added this to the needsTriage milestone Feb 15, 2019
@clydin clydin added area: @angular-devkit/build-angular type: bug/fix freq2: medium and removed area: @angular/cli freq1: low Only reported by a handful of users who observe it rarely labels Feb 15, 2019
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Feb 15, 2019
@clydin
Copy link
Member

clydin commented Feb 16, 2019

A PR to fix the loader resolution will be available shortly. This will enable building to work.
The following error is only occurring with serve actions and will require some additional investigation to solve.

ERROR in (webpack)/hot/emitter.js
Module not found: Error: Can't resolve 'events' in 'D:\dev\clones\test-pnpm\node_modules\.registry.npmjs.org\webpack\4.29.0\webpack@                                                  4.29.0\node_modules\webpack\hot'

clydin added a commit to clydin/angular-cli that referenced this issue Feb 20, 2019
…server

The dev server requires a node 'events' builtin shim to function.  The dev server as written only currently works with package managers that hoist the `events` shim package to an accessible location.  Hoisting is unfortantely not standardized and the assumption within the dev server will not hold true for all package managers.

Closes angular#13680
clydin added a commit to clydin/angular-cli that referenced this issue Feb 20, 2019
…server

The dev server requires a node 'events' builtin shim to function.  The dev server as written only currently works with package managers that hoist the `events` shim package to an accessible location.  Hoisting is unfortunately not standardized and the assumption within the dev server will not hold true for all package managers.

Closes angular#13680
clydin added a commit to clydin/angular-cli that referenced this issue Feb 20, 2019
…server

The dev server requires a node 'events' builtin shim to function.  The dev server as written only currently works with package managers that hoist the `events` shim package to an accessible location.  Hoisting is unfortunately not standardized and the assumption within the dev server will not hold true for all package managers.

Closes angular#13680
clydin added a commit to clydin/angular-cli that referenced this issue Feb 20, 2019
…server

The dev server requires a node 'events' builtin shim to function.  The dev server as written only currently works with package managers that hoist the `events` shim package to an accessible location.  Hoisting is unfortunately not standardized and the assumption within the dev server will not hold true for all package managers.

Closes angular#13680
clydin added a commit to clydin/angular-cli that referenced this issue Feb 20, 2019
…server

The dev server requires a node 'events' builtin shim to function.  The dev server as written only currently works with package managers that hoist the `events` shim package to an accessible location.  Hoisting is unfortunately not standardized and the assumption within the dev server will not hold true for all package managers.

Closes angular#13680
@lucas-labs
Copy link

I'm having this problem too when trying to use pnpm with angular. Is there any known workaround to solve this error other than shamefully-flatten? Thanks in advance!

@mbinic
Copy link

mbinic commented Jul 6, 2019

You can just install the missing dependencies (e.g. events), and since it's Webpack that's missing them, you can install to dev dependencies.

clydin added a commit to clydin/angular-cli that referenced this issue Jul 11, 2019
Webpack and its development server assume the presence of two node builtins (`events` & `querystring`).  Do to package hoisting npm/yarn will usually place the shims for those two builtins at locations that webpack find them.  This is however not guaranteed nor will it work with pnpm which strictly follows the prescribed dependency tree.
To remedy this, the specific node shims are enabled only for the specific internal webpack files that are used within the development server.  This ensures that the requirements of these files does not pollute the entire application.

Fixes angular#13680
clydin added a commit to clydin/angular-cli that referenced this issue Jul 11, 2019
Webpack and its development server assume the presence of two node builtins (`events` & `querystring`).  Do to package hoisting npm/yarn will usually place the shims for those two builtins at locations that webpack find them.  This is however not guaranteed nor will it work with pnpm which strictly follows the prescribed dependency tree.
To remedy this, the specific node shims are enabled only for the specific internal webpack files that are used within the development server.  This ensures that the requirements of these files does not pollute the entire application.

Fixes angular#13680
clydin added a commit to clydin/angular-cli that referenced this issue Jul 11, 2019
Webpack and its development server assume the presence of two node builtins (`events` & `querystring`).  Do to package hoisting npm/yarn will usually place the shims for those two builtins at locations that webpack find them.  This is however not guaranteed nor will it work with pnpm which strictly follows the prescribed dependency tree.
To remedy this, the specific node shims are enabled only for the specific internal webpack files that are used within the development server.  This ensures that the requirements of these files does not pollute the entire application.

Fixes angular#13680
vikerman pushed a commit that referenced this issue Jul 25, 2019
Webpack and its development server assume the presence of two node builtins (`events` & `querystring`).  Do to package hoisting npm/yarn will usually place the shims for those two builtins at locations that webpack find them.  This is however not guaranteed nor will it work with pnpm which strictly follows the prescribed dependency tree.
To remedy this, the specific node shims are enabled only for the specific internal webpack files that are used within the development server.  This ensures that the requirements of these files does not pollute the entire application.

Fixes #13680
vikerman pushed a commit that referenced this issue Jul 26, 2019
Webpack and its development server assume the presence of two node builtins (`events` & `querystring`).  Do to package hoisting npm/yarn will usually place the shims for those two builtins at locations that webpack find them.  This is however not guaranteed nor will it work with pnpm which strictly follows the prescribed dependency tree.
To remedy this, the specific node shims are enabled only for the specific internal webpack files that are used within the development server.  This ensures that the requirements of these files does not pollute the entire application.

Fixes #13680
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 9, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.