Skip to content
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

Problem with angular-electron? #24

Closed
drajvver opened this issue Sep 4, 2017 · 2 comments
Closed

Problem with angular-electron? #24

drajvver opened this issue Sep 4, 2017 · 2 comments

Comments

@drajvver
Copy link

drajvver commented Sep 4, 2017

Hello, I've got empty angular-electron app and wanted to add NFC to it. The problem is that when I copy the first example to HomeComponent I can't compile it.

ERROR in vendor.bundle.js from UglifyJs Unexpected token: name (ACR122Reader)
error comes out, any ideas?

Additionally this happens whenI try to run in dev mode.
I'm using the newest electron and nodejs.

@pokusew pokusew changed the title Problem with Webpack? Problem with angular-electron? Sep 4, 2017
@pokusew
Copy link
Owner

pokusew commented Sep 4, 2017

Hi @drajvver,

I'll sum up (just for the evidence) what we discussed and found out during our chat:

  1. According to the angular-electron documentation – Use NodeJS Native libraries:

    If you need to use NodeJS native libraries, you MUST add it manually in the file webpack.config.js in root folder ...

    So in this case you need to add "nfc-pcsc": "require('nfc-pcsc')" in the webpack.config.js externals section (for example below https://github.com/maximegris/angular-electron/blob/master/webpack.config.js#L226).

  2. Don't forget that you need to rebuild the native modules for Electron.

    You can do it for example by changing build:electron:main script in the package.json to the following:

    "tsc main.ts --outDir dist && copyfiles package.json dist && cd dist && npm install --target=1.7.5 --arch=x64 --target_arch=x64 --disturl=https://atom.io/download/electron --runtime=electron --build-from-source=true --prod && cd .."
    

    After that, don't forget to delete the dist folder and re-run npm start and npm electron:serve.

    Just note that's not the only solution. 🙂

With the changes

Hope it helps. 🙂


9th September 2017: I updated the comment with the fixed script and closed the issue, as the solution works. I also add note to the project README.


PS Don't forget to star ⭐️ my library, if you find it useful. 😃 Thanks.

@Canos
Copy link

Canos commented May 4, 2019

There is no webpack.config.js in recent versions of angular (as of 6.0).
So how can we configure nfc-pcsc in angular +6?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants