angular2-jwt: SystemJS js-base64 not found
Hey, I already had angular2-jwt installed and it was working well but for some reason I reinstalled the npm and it started to give this error. Then I installed the js-base64 manually with the command “npm i save-- @types/js-base64” and then the error changed to:
“(index):31 Error: (SystemJS) XHR error (404 Not Found) loading http://localhost:3000/buffer … Error loading http://localhost:3000/buffer as “buffer” from http://localhost:3000/node_modules/js-base64/base64.js”
In this moment I have the following dependencies in my package.json:
"@types/js-base64": "^2.1.4", "angular2-jwt": "^0.1.24", "js-base64": "^2.1.9",
Any idea of what is happenning?
Thanks for any help!
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 2
- Comments: 29 (6 by maintainers)
@danielserrao looking into this. For now you should be ok if you pin to v0.1.23.
@chenkie Thanks for the reply, I think we met last time in ng-conf. 😃 So I found the solution for this. Basically, dependencies we have to add the js-base64 and in devDependencies we have to add the @types/js-base64, then this error is not more there when we using ionic build. Hope this can help someone is updating their ionic2 app to RC.
Thanks
same problem here… “angular2-jwt”: “^0.1.24”, and also with 0.1.23 “buffer”: “^5.0.0”, “@types/js-base64”: “^2.1.4”,
edit:
got it working with 0.1.23 had to remove @types/js-base64 imports shoud look like ‘angular2-jwt/angular2-jwt’;
@escardin wrote up the config required to fix this problem in the readme https://github.com/auth0/angular2-jwt/commit/6b5816dc4f09f5603f7ea6ca9376c0650b80354b#diff-04c6e90faac2675aa89e2176d2eec7d8
Perhaps this thread can now be closed?
@georgeedwards confirm the version npm installed and get back to us. @bpblack My bad. I added the dep and ran unit tests, they ran okay and I didn’t realise that the lib tries to use buffer if you’re in a ‘node’ environment.
I tracked the issue down to SystemJS doesn’t manage your transitive dependencies for you.
If you add the following to your SystemJS config in the map section:
If you’re using the Angular CLI, I think you might need to also tell angular about js-base64. I haven’t really used the CLI, and I’m a webpack user myself, so these sorts of things don’t generally come up.
If something needs to be added elsewhere, please let me know so I can update the docs (I’m already going to update them for SystemJS).