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.
Related
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.
I ran into a weird issue with my recent Nextjs build that I cannot figure out. Any page other than the index.js page throws an error saying that Fast Refresh had to perform a full reload whenever I make a change to the page.
Nextjs version: 12.2.3
React version: 17.0.2
The error in the terminal (no console errors):
Fast Refresh had to perform a full reload. Read more: https://nextjs.org/docs/basic-features/fast-refresh#how-it-works
Error: Aborted because ./pages/contact.js is not accepted
Update propagation: ./pages/contact.js -> ./node_modules/next/dist/build/webpack/loaders/next-client-pages-loader.js?absolutePagePath=D%3A%5Csites%5Coverpeaks%5Coverpeaks-nextjs%5Cpages%5Ccontact.js&page=%2Fcontact!
at applyHandler (http://localhost:3000/_next/static/chunks/webpack.js?ts=1669755499923:869:31)
at http://localhost:3000/_next/static/chunks/webpack.js?ts=1669755499923:552:21
at Array.map (<anonymous>)
contact.js:
const contact = () => {
return <div>contact</div>;
};
export default contact;
next.config.js:
/**
* #type {import('next').NextConfig}
*/
module.exports = {
experimental: {
images: {
allowFutureImage: true,
},
},
images: {
domains: ["cms.overpeaks.ca"],
},
webpack: (config) => {
config.resolve = {
...config.resolve,
fallback: {
fs: false,
path: false,
os: false,
},
};
return config;
},
};
What my structure looks like:
image
I noticed this while working on my about.js page, so I thought it might have to do with the code within there, so I created a brand new page (contact.js) and am having the same issue. I've tried removing everything within next.config.js with no difference. At this point I'm starting to think there's a bug within Nextjs causing this.
Error: Webpack Compilation Error ./client/src/containers/Login.jsx
Module not found: Error: Can't resolve 'Src/api' in
'/Users/user/Documents/product-bots/client/src/containers' resolve
'Src/api' in
'/Users/sathish/Documents/product-bots/client/src/containers' Parsed
request is a module using description file:
/Users/sathish/Documents/product-bots/client/package.json (relative
path: ./src/containers)
I am trying to set up and run cypress inside a react.js app. There is an import statement in the app that says import api from 'Src/api. Cypress fails at this point and throws the above error.
Can anyone please help me to resolve this issue?
Below is the test code
import Login from '../../../client/src/containers/Login'
describe('Login', () => {
it('Tries login', () => {
mount(<Login />)
cy.get('.login-form').should('exist')
})
})
The above code calls login.jsx which has the 'Src/api' import.
jsconfig.js:
"paths": {"Src/*": ["src/*"] }
webpack.config.js:
alias: { Src: path.resolve(Paths.srcDir)
I had a CSR app and now implemented Server-Side Rendering (SSR) with React, and get this error
Error: Couldn't find a style target
We used reactDOMserver, react-app-wire, with webpack-override file
See webpack configs below:
const { resolve } = require("path");
require("ignore-styles");
module.exports = {
webpack: function (config) {
config.entry = resolve(dirname, "../client/src/ssr");
config.optimization = undefined;
config.output = {
filename: "ssr.js",
globalObject: 'this',
libraryTarget: "commonjs",
path: resolve(dirname, "../client/build"),
};
return config;
},
};
from server
app.get("^/$", (req, res) => {
Object.assign(global, {
navigation: {},
window: ssr.getWindow(),
navigator: {
userAgent: req.headers["user-agent"],
},
global: {},
document:ssr.ssrDocument
});
const App = require("./build/ssr");
const context = {};
let app = App.default(req.url, context);
then res,render app
AND SSR JS FILE
ssr.js file :
import { renderToString } from "react-dom/server";
for renderToString(
....
<App/>
....
)
And received Error: Couldn't find a style target
I had a CSR app and now implemented Server-Side Rendering (SSR) with React, and get this error
Error: Couldn't find a style target. This probably means that the value for the 'insert' parameter is invalid
Get this error when I run the server and try to access the page.
We also tried other approaches with these loaders:
css-loader, sass loader and style-loader and even with isomorphic-style-loader
They led to the error with No PostCSS config and after fixing this by adding to the project postcss.config.js file AND AFTER we received same error about style target and additional error with antd
Error: No PostCSS Config found in: D:_PROJECT....\client\node_modules\antd\dist
Tech sack in use: nodejs, reactjs, antdesign, babel and webpack.
I already tried a lot of solutions from StackOverflow and other sources, nothing helped!
Please, help me to solve it.
Thank you!
I think you cannot use style-loader server side.
Find the loader like this: https://github.com/codebandits/react-app-rewire-css-modules/blob/master/index.js just use style-loader instead, and remove it.. or switch to razzle
I was working with my Angular files and viewed it using browser-sync in gulp. The Angular views won't load in the browser and throws an error in Chrome Console that pointed out socket.io.
These are the error messages:
Uncaught Error: [$injector:nomod] http://errors.angularjs.org/1.5.0-beta.2/$injector/nomod?p0=portfolio
Failed to load resource: net::ERR_CONNECTION_REFUSED
GET http://localhost:3000/browser-sync/socket.io/?EIO=3&transport=polling&t=1452587505197-14 net::ERR_CONNECTION_REFUSED
This is in my gulpfile
var browserSync = require('browser-sync');
gulp.task('browser-sync', function () {
var files = [
'*.html',
'css/**/*.css',
'js/**/*.js'
];
browserSync.init(files, {
server: {
baseDir: './'
}
});
});
I tried to use Live Preview in Brackets. Everything works fine with Angular. Is there something I need to change in my gulp files so it will load the Angular views?