Node Modules
See original GitHub issueHow to use native node modules?
import { Component } from '@angular/core';
import * as c from 'child_process';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss']
})
export class AppComponent {
title = 'app works!';
constructor() {
console.log('c', c);
}
}
Webpack error:
$ npm run build
> angular-electron@1.0.3 build C:\Users\daniel\projects\angular-electron
> ng build && copyfiles main.js dist
Hash: f817a55010bbe497b5df
Time: 8290ms
chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 158 kB {4} [initial] [rendered]
chunk {1} main.bundle.js, main.bundle.js.map (main) 3.98 kB {3} [initial] [rendered]
chunk {2} styles.bundle.js, styles.bundle.js.map (styles) 9.89 kB {4} [initial] [rendered]
chunk {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.07 MB [initial] [rendered]
chunk {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
ERROR in C:/Users/daniel/projects/angular-electron/src/app/app.component.ts (2,20): Cannot find module 'child_process'.
ERROR in C:/Users/daniel/projects/angular-electron/src/app/app.component.ts (2,20): Cannot find module 'child_process'.
ERROR in ./src/app/app.component.ts
Module not found: Error: Can't resolve 'child_process' in 'C:\Users\daniel\projects\angular-electron\src\app'
@ ./src/app/app.component.ts 11:0-35
@ ./src/app/app.module.ts
@ ./src/main.ts
@ multi ./src/main.ts
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
CommonJS modules | Node.js v19.3.0 Documentation
CommonJS modules are the original way to package JavaScript code for Node.js. Node.js also supports the ECMAScript modules standard used by browsers and ......
Read more >Node.js Modules - W3Schools
What is a Module in Node.js? Consider modules to be the same as JavaScript libraries. A set of functions you want to include...
Read more >node-modules - npm
commandline tool and node module for node-modules.com. Latest version: 1.0.1, last published: 7 years ago. Start using node-modules in your ...
Read more >Node.js Modules - GeeksforGeeks
In Node.js, Modules are the blocks of encapsulated code that communicates with an external application on the basis of their related ...
Read more >Install Node.js modules - Bitnami Documentation
Using it, you can install, uninstall and search for Node.js modules. npm installs modules in two different scopes: local and global. Local installation....
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
Hi,
By default, angular-cli doesn’t seem to be able to import nodeJS native libs or electron libs. The best solution is to override webpack configuration.
I did a test and it seems to work
I pushed the fix on the master branch and add a new tag 1.1.0. You have to do a yarn or npm installation to install the new dependencies.
Tell me if this correction fix your error.
Kindly point some links/tutorials to do this.