It works fine when i run with node Express server (I use #ng-toolkit/universal) But with aspnet core node engine throwing NodeInvocation Exception Reference Error: Window is not defined in a third party modules like ngx-bootstrap and angular-jwt.
NodeInvocationException: Prerendering failed
because of error: ReferenceError: window is not
defined
at Object.<anonymous>
(C:\2ndCustomer\Angular6\node_modules\#auth0\angular-
jwt\bundles\core.umd.js:1:704)
And ngx-bootstrap error but when i run with express server.ts it works fine
https://github.com/maciejtreder/ng-toolkit
Related
The below error occurs when running npm test in a SharePoint Framework web part with a react component that imports DisplayMode from '#microsoft/sp-core-library':
export { default as _BrowserDetection } from './BrowserDetection';
^^^^^^
SyntaxError: Unexpected token export
Following the resolution steps mentioned in https://github.com/SharePoint/sp-dev-docs/issues/2325#issuecomment-446416878 works fine for testing but fails for the build process.
I've been using msal.js for authentication in my Angular application. This is working fine for development builds using ng serve. Unfortunately this library gives me an error when I try to run a server build using node. This build is generated using npm run build:prod and served by using npm run server. After attempting to serve this using node, the following error occurs:
/Users/mikey/Documents/projectname-angular8/dist/server.js:170525
class WindowWrapper extends Window {
^
ReferenceError: Window is not defined
at Module.<anonymous> (/Users/mikey/Documents/projectname-angular8/dist/server.js:170525:29)
at __webpack_require__ (/Users/mikey/Documents/projectname-angular8/dist/server.js:21:30)
at Object.#azure/msal-angular/dist/msal.module (/Users/mikey/Documents/projectname-angular8/dist/server.js:148059:18)
at __webpack_require__ (/Users/mikey/Documents/projectname-angular8/dist/server.js:141641:30)
at Object../src/app/app.server.module.ngfactory.js (/Users/mikey/Documents/projectname-angular8/dist/server.js:142963:13)
at __webpack_require__ (/Users/mikey/Documents/projectname-angular8/dist/server.js:141641:30)
at Object../src/main.server.ts (/Users/mikey/Documents/projectname-angular8/dist/server.js:147883:37)
at __webpack_require__ (/Users/mikey/Documents/projectname-angular8/dist/server.js:141641:30)
at Object.0 (/Users/mikey/Documents/projectname-angular8/dist/server.js:147904:18)
at __webpack_require__ (/Users/mikey/Documents/projectname-angular8/dist/server.js:141641:30)
I can understand why the error is happening, but as this third party library is required, I am unable to remove this package from the project all together. I've tried only loading this part of the code in app.browser.module.ts but then I am having injection errors when attempting to run the server side version in the browser.
I hope someone can explain me how I can make a runnable server side build of this project while using this third party library.
I'm getting a Error: fs.existsSync is not a function code after I bundle my code using Browserify.
Before I've tried to use require() but I kept getting Error: require is not defined due to require function not supported on client side. Browserify seems a solution to use. I've managed to solve require error with browserify but another one came up - fs.existsSync is not a function.
Here is the error code as shown on my console:
Error: fs.existsSync is not a function
[159]</</sqlite.prototype.connect#http://127.0.0.1:8080/services/bundle.js:169566:35
[160]</<#http://127.0.0.1:8080/services/bundle.js:169992:29
invoke#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:4718:19
enforcedReturnValue#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:4557:37
invoke#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:4718:19
createInjector/protoInstanceInjector<#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:4517:37
getService#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:4664:39
injectionArgs#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:4688:58
instantiate#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:4730:18
$controller#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:10369:28
compile/<#http://127.0.0.1:8080/views/assets/js/vendors/angular-ui-router.js:4081:28
bind/<#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:1247:18
invokeLinkFn#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:9934:9
nodeLinkFn#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:9335:11
compositeLinkFn#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:8620:13
publicLinkFn#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:8500:30
lazyCompilation#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:8844:25
updateView#http://127.0.0.1:8080/views/assets/js/vendors/angular-ui-router.js:4021:23
compile/</<#http://127.0.0.1:8080/views/assets/js/vendors/angular-ui-router.js:3959:11
$broadcast#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:18005:28
transitionTo/$state.transition<#http://127.0.0.1:8080/views/assets/js/vendors/angular-ui-router.js:3352:22
processQueue#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:16383:28
scheduleProcessQueue/<#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:16399:27
$eval#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:17682:28
$digest#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:17495:31
$apply#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:17790:24
done#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:11831:47
completeRequest#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:12033:7
requestLoaded#http://127.0.0.1:8080/views/assets/js/vendors/angular.js:11966:9
<div ui-view="" class="ng-scope">
I'm using electron, angularjs and sqlite to build my app but I'm stuck on this error, any help will be appreciated.
I've managed to solve my error without browserify by enabling nodeIntegration: true in main.js file (electron entry file). Then I was able to load my script (coolscript.js) which has require function inside of it to my html without problems -
<script>
require('coolscript.js')
</script>
I'm playing with the Google Cloud API Speech-to-Text Node client library. Works quite well, and well described in their documentation.
Problems come when I wanted to use it in a VueJS : it simply seems not to be supported.
First attempt :
npm run serve returns
ERROR Failed to compile with 3 errors 11:35:13
This dependency was not found:
* http2 in ./node_modules/#grpc/grpc-js/build/src/channel.js, ./node_modules/#grpc/grpc-js/build/src/subchannel.js and 1 other
But http2 is a core module in Node now, and when I run node -p http2 I do get results.
Second attempt :
npm i http2
npm run serve returns
WARNING Compiled with 1 warnings 11:41:07
warning in ./node_modules/http2/lib/protocol/index.js
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
In browser, console provides error
Uncaught Error: not supported
at Root.loadSync (root.js?ee6e:234)
at Object.loadSync (index-light.js?071f:69)
at Object.eval (index.js?f193:244)
at eval (index.js:250)
at Object../node_modules/#grpc/proto-loader/build/src/index.js (app.js:1383)
at __webpack_require__ (app.js:724)
at fn (app.js:101)
at Object.eval (grpc.js?6f5f:34)
at eval (grpc.js:288)
at Object../node_modules/google-gax/build/src/grpc.js
My Vue App is basic and can be retrieved using vue-cli by running vue create app. I then added in the HelloWorld Component the basic code displayed in the quickstart guide.
My theory is : VueJS can't use google-gax module due to gRPC. What do you think ?
Currently the Google Cloud API client libraries such as the one you are using cannot be used from the browser. As you noted, those libraries use gRPC, which in turn uses http2. The problem is that currently no major browser allows JavaScript libraries to use the full functionality of the HTTP/2 protocol, so there is currently no complete browser shim for the Node http2 module.
The http2 module you got from npm is a different library with a different API. It most likely also does not work in the browser for the same reason.
I have installed npm, Yeoman and got everything working, the webapp generator works like a charm. I want to get into angular development and therefore tested the generator-angular.
I did everything as stated in the readme file
npm install -g generator-angular
yo angular [app-name]
then
grunt
grunt serve
at grunt i got this error:
WARN [watcher]: Pattern "/home/user/angular/test/mock/*/.js" does not match any file.
INFO [Chrome 31.0.1650 (Linux)]: Connected on socket 3juFgfMcw5Pm88-cve27
Chrome 31.0.1650 (Linux) Controller: MainCtrl should attach a list of awesomeThings to the scope FAILED
Error: [$injector:modulerr] Failed to instantiate module testApp due to:
Error: [$injector:unpr] Unknown provider: $routeProvider
The main error - is with "unknown" $routeProvider.
Check if ngRoute module has been loaded.
Also check that you propely injected it to your testApp module.
It would be great if you could provide your testApp code.
Also I guess that you have an error with regex (no escape symbol)
/home/user/angular/test/mock/**/*.js
Try this "/home/user/angular/test/mock/*\.js"
/home/user/angular/test/mock/**/*\.js