Will ng2-bootstrap work with RC6? - ng2-bootstrap

Has anyone used ng2-bootstrap with RC6?
I do this in app.module (following the instructions on gitHub):
import {AlertModule} from 'ng2-bootstrap/ng2-bootstrap';
#NgModule({
imports: [BrowserModule, AlertModule],
exports: [],
providers: [],
declarations: [AppComponent],
bootstrap: [AppComponent]
})
I get an error at runtime:
syntaxError: Unexpected token <

syntaxError: Unexpected token <
Means that system.js made a request for .js file and got html (404 or index.html) in response, you need to properly config system.js
or use webpack ;)
you can get more help in official slack channel https://www.hamsterpad.com/chat/ng2

Related

Uncaught ReferenceError: require is not defined at bundle.js(es-build)

I am using an esbuild API build to bundle a basic React app . But it keeps bringing up the following error Uncaught ReferenceError: require is not defined at bundle.js.Below is my build.js code.
const esbuild = require('esbuild');
async function build() {
await esbuild.build({
entryPoints: ['index.js'],
outfile: './build/bundle.js',
format: 'cjs',
loader: { '.js': 'jsx' },
});
}
build();
What I tried:
Clearing terminal history.
Deleting bundle.js and regenerating it again
Restarting vs-code.
Try to change the scope of require to the scope where you are trying to use it.
I replaced const esbuild = require('esbuild'); with import esbuild from 'esbuild'; and changed the format to iife. And it worked.

"yarn/Vite" build results in a Uncaught TypeError

This is a weird one, my react application can run without any trouble, but when I ran a yarn:build, the built dist cannot be hosted properly even though the build was successful. Following is the console output.
Uncaught TypeError: e is not a constructor
at ETe (index.504b65a0.js:323:24562)
at Ce (index.504b65a0.js:335:4732)
at index.504b65a0.js:313:68312
The most recent update I did was introducing aws-sdk to the code. And while I bumped into Uncaught ReferenceError: global is not defined and Failed to resolve entry for package "fs"., I added couple of fields in my Vite.config.
import { defineConfig } from 'vite';
import createVitePlugins from './config/plugins';
import cssOption from './config/style';
import { VITE_APP_BASE, VITE_APP_PORT, VITE_APP_OPEN } from './config';
import proxy from './config/setupProxy';
import path from 'path';
import build from './config/build';
export default defineConfig(() => {
return {
base: VITE_APP_BASE,
plugins: createVitePlugins(),
css: cssOption,
server: {
host: true,
port: VITE_APP_PORT,
open: VITE_APP_OPEN,
proxy,
},
define: {
global: 'window', // <----------- to resolve global
},
resolve: {
alias: {
'#': path.resolve(__dirname, 'src'),
fs: require.resolve('rollup-plugin-node-builtins'), // <-------- to resolve fs
},
},
build,
};
});
Since the code is running fine in development mode, I don't really know what could the problem be and where shall I look into. Please let me know what other information do I have to provide to properly debug this issue.

Cypress TypeScript error : Cannot find module #angular/core for my react app

I'm trying to migrate to Cypress 10.7.0 from 9.70. However almost fixed all the bug but stuck here at strange message, which says #angular/core or its corresponding type declarations cannot be found.
My app is a react app so why Cypress look for Angular not even mentioned in any config.
TypeScript error: /Users/vinay/cypress_testing_service/node_modules/cypress/angular/dist/mount.d.ts(5,22): Error TS2307: Cannot find module '#angular/core' or its corresponding type declarations.
at ProjectConfigIpc.<anonymous> (/Users/vinay/Library/Caches/Cypress/10.7.0/Cypress.app/Contents/Resources/app/packages/data-context/src/data/ProjectConfigManager.js:216:60)
at Object.onceWrapper (node:events:646:26)
at ProjectConfigIpc.emit (node:events:526:28)
at ProjectConfigIpc.emit (node:domain:475:12)
at ProjectConfigIpc.emit (/Users/vinay/Library/Caches/Cypress/10.7.0/Cypress.app/Contents/Resources/app/packages/data-context/src/data/ProjectConfigIpc.js:64:22)
at ChildProcess.<anonymous> (/Users/vinay/Library/Caches/Cypress/10.7.0/Cypress.app/Contents/Resources/app/packages/data-context/src/data/ProjectConfigIpc.js:40:18)
at ChildProcess.emit (node:events:526:28)
at ChildProcess.emit (node:domain:475:12)
at emit (node:internal/child_process:938:14)
at processTicksAndRejections (node:internal/process/task_queues:84:21)
Including Cypress.config.ts contents for ref.
import { defineConfig } from "cypress";
export default defineConfig({
viewportWidth: 1366,
viewportHeight: 768,
reporter: "mocha-junit-reporter",
reporterOptions: {
mochaFile: "cypress/reports/junit/test-results.[hash].xml",
testsuitesTitle: false,
},
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
// https://docs.cypress.io/guides/references/migration-guide#Plugins-File-Removed
setupNodeEvents(on, config) {
return require("./cypress/plugins/index.ts")(on, config);
},
baseUrl: "http://localhost:8082/",
specPattern: "cypress/e2e/**/*.feature",
},
component: {
devServer: {
framework: "create-react-app",
bundler: "webpack",
},
},
});
Reading the error TypeScript error: /Users/vinay/cypress_testing_service/node_modules/cypress/angular/dist/mount.d.ts(5,22): Error TS2307: Cannot find module '#angular/core' or its corresponding type declarations.
It looks like the new component testing feature type definitions mount.d.ts are being loaded for angular (instead of react).
Your config looks correct i.e.
component: {
devServer: {
framework: "create-react-app",
bundler: "webpack",
},
},
So, Create an issue here : https://github.com/cypress-io/cypress/issues with a reproducible example 🤞🏻

JWT for angular2 based on systemJS

I have tried the github tutorial to use JWT
https://github.com/auth0/angular2-jwt
after that I have edited the systemjs file as follow.
System.config({
packages: {
"/angular2-jwt": {
"defaultExtension": "js"
}
},
map: {
"angular2-jwt": "node_modules/angular2-jwt/angular2-jwt.js"
}
});
but im having an issue : Uncaught (in promise): Error: No provider for Http!
this error goes when I remove authHttp from the constructor.

Ionic app shows not http provider error

I am trying to implement a http request in ionic framework 3.1 application. I have created a provider named apidata using ionic g provider apidata command after which i created the following function in it that calls the api and logs the data returned by it on console.
getremotedata(){
console.log(this.http.get('https://reverie.oiamigotech.com/wp-json/wc/v2/products/?consumer_key=ck_xyz&consumer_secret=cs_xyz'));
}
and have also imported the http package in the header as import { Http } from '#angular/http';
after which I updated the app.module.ts file to import the provider as import { ApidataProvider } from '../providers/apidata/apidata'; and also added the same to the provider list as providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler},
ApidataProvider
]
now when i try to call the same from the home page after importing the package and using the following function and constructor definition
constructor(public navCtrl: NavController,public ApidataService: ApidataProvider) {
}
ionViewDidLoad(){
this.ApidataService.getremotedata();
}
It generated the following error Uncaught (in promise): Error: No provider for Http!
referred to https://www.youtube.com/watch?v=vuc4dp0qHSc for instructions about integration.
I am new to ionic and am unable to find and debug the issue. Any suggestions are greatly welcomed.
import HttpModule and add it in app.module.ts page under imports like this,
import { HttpModule } from '#angular/http';
imports: [
BrowserModule,
HttpModule,
IonicModule.forRoot(MyApp)
]
remove any other http imports in your app.module.ts page and that should work

Resources