I am new to react.js . My applicaition is base on google map . I tried to integrate with react js but it show follwoing error :
PS E:\FYP\demo projects\map\my-app> npm install --save google-maps-react
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: my-app#0.1.0
npm ERR! Found: react#18.2.0
npm ERR! node_modules/react
npm ERR! react#"^18.2.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"~0.14.8 || ^15.0.0 || ^16.0.0" from google-maps-react#2.0.6
Failed to compile.
Here is the code :
import './App.css';
import {Map, InfoWindow, Marker, GoogleApiWrapper} from 'google-maps-react';
import React from "react";
function App() {
return (
<div className="App">
<header className="App-header">
<Map google={this.props.google} zoom={14}>
<Marker onClick={this.onMarkerClick}
name={'Current location'} />
<InfoWindow onClose={this.onInfoWindowClose}>
<div>
<h1>{this.state.selectedPlace.name}</h1>
</div>
</InfoWindow>
</Map>
</header>
</div>
);
}
export default GoogleApiWrapper({ apiKey: ("AIzaSyBwl84ZlMZeFUjUxCQK0MMEh5QL_0SRtfI")
})(App)
ERROR in ./src/App.js 5:0-78
Module not found: Error: Can't resolve 'google-maps-react' in 'E:\FYP\demo projects\map\my-app\src'
I just cloned the Next Auth Example, changed ports in package.json to match my server and added my domain in .env.local. Because of WASM middleware in Next 12, I had to downgrade to Next 11, so I just edited package.json to "next": "^11.1.3" and ran npm i again.
When I try to npm run build, I get this error:
ModuleNotFoundError: Module not found: Error: Can't resolve 'next/server' in 'domain.com/pages'
The npm run dev works fine.
The page that has the server import is:
https://github.com/nextauthjs/next-auth-example/blob/main/pages/_middleware.js
import { getToken } from "next-auth/jwt"
import { NextResponse } from "next/server"
/** #param {import("next/server").NextRequest} req */
export async function middleware(req) {
if (req.nextUrl.pathname === "/middleware-protected") {
const session = await getToken({
req,
secret: process.env.SECRET,
secureCookie:
process.env.NEXTAUTH_URL?.startsWith("https://") ??
!!process.env.VERCEL_URL,
})
// You could also check for any property on the session object,
// like role === "admin" or name === "John Doe", etc.
if (!session) return NextResponse.redirect("/api/auth/signin")
// If user is authenticated, continue.
}
}
Full Log:
> next-auth-example#0.0.0 build /domain.com
> next build
info - Loaded env from /domain.com/.env.local
info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
info - Checking validity of types
warn - No ESLint configuration detected. Run next lint to begin setup
info - Creating an optimized production build
Failed to compile.
ModuleNotFoundError: Module not found: Error: Can't resolve 'next/server' in 'domain.com/pages'
> Build error occurred
Error: > Build failed because of webpack errors
at domain.com/node_modules/next/dist/build/index.js:397:19
at async Span.traceAsyncFn (domain.com/node_modules/next/dist/telemetry/trace/trace.js:60:20)
at async Object.build [as default] (domain.com/node_modules/next/dist/build/index.js:77:25)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! next-auth-example#0.0.0 build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the next-auth-example#0.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! domain.com/.npm/_logs/blahblahblah-debug.log // I edited this line
package.json
{
"name": "authentication",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"author": "damn",
"license": "ISC",
"dependencies": {
"next": "^11.1.2",
"next-auth": "^4.1.2",
"react": "^17.0.2",
"react-dom": "^17.0.2"
}
}
(removed -p since it had no effect in my environment)
What's causing the problem and how should I solve it?
Middleware as a concept was introduced with NextJS 12 - See here - https://nextjs.org/blog/next-12#introducing-middleware
For your usecase, see here and follow the api routes example.
I have created a new project with ANGULAR 12, I am trying to add Jest.js to this project, but I get the next error.
TypeError: Jest: a transform must export something.
at D:\Refraccion\SOFTWARE----\TDD and DBB\demo1\node_modules\#jest\transform\build\ScriptTransformer.js:386:19
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Promise.all (index 0)
at async ScriptTransformer.loadTransformers (D:\Refraccion\SOFTWARE----\TDD and DBB\demo1\node_modules\#jest\transform\build\ScriptTransformer.js:378:5)
at async createScriptTransformer (D:\Refraccion\SOFTWARE----\TDD and DBB\demo1\node_modules\#jest\transform\build\ScriptTransformer.js:1106:3)
at async D:\Refraccion\SOFTWARE----\TDD and DBB\demo1\node_modules\#jest\core\build\TestScheduler.js:269:31
at async Promise.all (index 0)
at async TestScheduler.scheduleTests (D:\Refraccion\SOFTWARE----\TDD and DBB\demo1\node_modules\#jest\core\build\TestScheduler.js:262:5)
at async runJest (D:\Refraccion\SOFTWARE----\TDD and DBB\demo1\node_modules\#jest\core\build\runJest.js:387:19)
at async _run10000 (D:\Refraccion\SOFTWARE----\TDD and DBB\demo1\node_modules\#jest\core\build\cli\index.js:408:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! demo1#0.0.0 test: `jest`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the demo1#0.0.0 test script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Tom\AppData\Roaming\npm-cache\_logs\2021-06-06T22_50_07_345Z-debug.log
jest.config.js
module.exports = {
moduleNameMapper: {
'#core/(.*)': '<rootDir>/src/app/core/$1',
},
preset: 'jest-preset-angular',
setupFilesAfterEnv: ['<rootDir>/setup-jest.ts'],
};
package.json
{
"name": "demo1",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"test": "jest",
}
}
Is there some way to fix it in ANGULAR?
Experienced the same thing when I tried to create a new project, so far it isn't compatible with the newest Angular 12 yet that I know of.
Currently learning Vue js and express js through some tutorials, I am still newbie regarding these technologies.
Anyway following the tutorials I am building a small project in which I have a folder "Client" that contains the frontend side of the project and another folder "Server" that contains the backend.
Just before pushing commits to Github, everything was fine, but once I did Github signals some vulnerabilities and after fixing them npm run dev doesn't work anymore.
tried multiples solutions but nothing worked, reinstalled suspicious modules, reinstalled node modules after running npm cache clean --force
This is the error I got
npm run dev
> client#1.0.0 dev D:\projects\Fullstack web apps\VueJs ExpressJs\tab-tracker\Client
> webpack-dev-server --inline --progress --config build/webpack.dev.conf.js
D:\projects\Fullstack web apps\VueJs ExpressJs\tab-tracker\Client\node_modules\copy-webpack-plugin\node_modules\schema-utils\dist\validate.js:88
throw new _ValidationError.default(errors, schema, configuration);
^
ValidationError: Invalid options object. Copy Plugin has been initialized using an options object that does not match the API schema.
- options[0] misses the property 'patterns'. Should be:
[non-empty string | object { from, to?, context?, globOptions?, toType?, force?, flatten?, transform?, cacheTransform?, transformPath?, noErrorOnMissing? }, ...] (should not have fewer than 1 item)
at validate (D:\projects\Fullstack web apps\VueJs ExpressJs\tab-tracker\Client\node_modules\copy-webpack-plugin\node_modules\schema-utils\dist\validate.js:88:11)
at new CopyPlugin (D:\projects\Fullstack web apps\VueJs ExpressJs\tab-tracker\Client\node_modules\copy-webpack-plugin\dist\index.js:24:30)
at Object.<anonymous> (D:\projects\Fullstack web apps\VueJs ExpressJs\tab-tracker\Client\build\webpack.dev.conf.js:61:5)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Module.require (internal/modules/cjs/loader.js:1019:19)
at require (internal/modules/cjs/helpers.js:77:18)
at WEBPACK_OPTIONS (D:\projects\Fullstack web apps\VueJs ExpressJs\tab-tracker\Client\node_modules\webpack-cli\bin\utils\convert-argv.js:114:13)
at requireConfig (D:\projects\Fullstack web apps\VueJs ExpressJs\tab-tracker\Client\node_modules\webpack-cli\bin\utils\convert-argv.js:116:6)
at D:\projects\Fullstack web apps\VueJs ExpressJs\tab-tracker\Client\node_modules\webpack-cli\bin\utils\convert-argv.js:123:17
at Array.forEach (<anonymous>)
at module.exports (D:\projects\Fullstack web apps\VueJs ExpressJs\tab-tracker\Client\node_modules\webpack-cli\bin\utils\convert-argv.js:121:15)
at Object.<anonymous> (D:\projects\Fullstack web apps\VueJs ExpressJs\tab-tracker\Client\node_modules\webpack-dev-server\bin\webpack-dev-server.js:84:40)
at Module._compile (internal/modules/cjs/loader.js:1133:30) {
errors: [
{
keyword: 'required',
dataPath: '[0]',
schemaPath: '#/required',
params: [Object],
message: "should have required property 'patterns'",
schema: [Object],
parentSchema: [Object],
data: [Object],
children: [Array]
}
],
schema: {
definitions: { ObjectPattern: [Object], StringPattern: [Object] },
type: 'object',
additionalProperties: false,
properties: { patterns: [Object], options: [Object] },
required: [ 'patterns' ]
},
headerName: 'Copy Plugin',
baseDataPath: 'options',
postFormatter: null
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client#1.0.0 dev: `webpack-dev-server --inline --progress --config build/webpack.dev.conf.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client#1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\iheb\AppData\Roaming\npm-cache\_logs\2020-05-21T13_56_52_099Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client#1.0.0 start: `npm run dev`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\iheb\AppData\Roaming\npm-cache\_logs\2020-05-21T13_56_52_148Z-debug.log
This is the log file :
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'run',
1 verbose cli 'build:server'
1 verbose cli ]
2 info using npm#6.14.4
3 info using node#v12.16.3
4 verbose stack Error: missing script: build:server
4 verbose stack at run (C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:155:19)
4 verbose stack at C:\Program Files\nodejs\node_modules\npm\lib\run-script.js:63:5
4 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:116:5
4 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:436:5
4 verbose stack at checkBinReferences_ (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:391:45)
4 verbose stack at final (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:434:3)
4 verbose stack at then (C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:161:5)
4 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\read-package-json\read-json.js:281:12
4 verbose stack at C:\Program Files\nodejs\node_modules\npm\node_modules\graceful-fs\graceful-fs.js:115:16
4 verbose stack at FSReqCallback.readFileAfterClose [as oncomplete] (internal/fs/read_file_context.js:63:3)
5 verbose cwd D:\projects\Fullstack web apps\VueJs ExpressJs\tab-tracker\Client
6 verbose Windows_NT 10.0.18362
7 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "build:server"
8 verbose node v12.16.3
9 verbose npm v6.14.4
10 error missing script: build:server
11 verbose exit [ 1, true ]
Running npm audit gives the following :
Moderate Cross-Site Scripting
Package serialize-javascript
Patched in >=2.1.1
Dependency of uglifyjs-webpack-plugin [dev]
Path uglifyjs-webpack-plugin > serialize-javascript
More info https://npmjs.com/advisories/1426
Related dependencies
"webpack": "^4.43.0",
"webpack-bundle-analyzer": "^3.3.2",
"webpack-cli": "^3.3.11",
"webpack-dev-server": "^3.1.11",
I hope I provided everything for you guys, if not I will immediately provide anything to help clarify my problem, as I said I'm a newbie to web development.
UPDATE: I've trying to figure out the reason behind such error, the problem occurs after updating webpack-dev-server
Version that works :
"webpack-dev-server": "^2.9.1"
Version with errors :
"webpack-dev-server": "^3.11.0"
Is it okay if I ignore vulnerabilities found? Because trying to fix them causes this error.
Thanks
This is not an issue with webpack or webpack-dev-server itself, but with the copy-webpack-plugin plugin.
With the update to the 6.x major version came a breaking change: instead of just passing the array with the config patterns directly to the CopyWebpackPlugin constructor, your now have to wrap it in the patterns property of an object and pass that.
Old syntax:
new CopyWebpackPlugin(
[
{ from: 'src/xxx.ext', to: 'dist/xxx.ext' },
{ from: 'src/yyy.ext', to: 'dist/yyy.ext' }
]
)
New syntax:
new CopyWebpackPlugin(
{
patterns: [
{ from: 'src/xxx.ext', to: 'dist/xxx.ext' },
{ from: 'src/yyy.ext', to: 'dist/yyy.ext' }
]
}
)
They did that because the constructor now supports an additional options property:
https://webpack.js.org/plugins/copy-webpack-plugin/#options-1
After updating to 3.11 a new template appeared
plugins: [
new CopyPlugin({
patterns: [
{ from: 'source', to: 'dest' },
{ from: 'other', to: 'public' },
],
}),
],
I had the same problem. Finally, I was able to solve it using
npm install --save copy-webpack-plugin#5.1.1
If you upgrade to copy-webpack-plugin: ^6.0.3 in your package.json then following should work, when you previously copied a whole directory:
plugins: [
new CopyWebpackPlugin({
patterns: [
{
from: "[your-src-dir]/*",
to: "[your-dst-dir]/*",
},
],
}),
]
adding /* after directory target and source directory name fixed it without ignoring vulnerability, which you should never do.
Take a look at https://webpack.js.org/plugins/copy-webpack-plugin/ for more.
this works for me
at webpack.config.js file change the CopyWebpackPlugin
new CopyWebpackPlugin({
patterns: [
{ from: "fonts/**", globOptions: { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] } },
{ from: "**/*.{jpg,png}", globOptions: { ignore: [`${relative(appPath, appResourcesFullPath)}/**`] } },
]
}),
hope I help
Reset angular toolkit version to 2.3.0 using the below command.
npm i #ionic/angular-toolkit#2.3.0 -E -D
I am learning ReactJS. The installation has been done but when I run this npm command, I get the following error.
me#R-SOFT-85:/var/www/reactjsbasics$ npm run build
> reactjsbasics#1.0.0 build /var/www/reactjsbasics
> webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --watch
/var/www/reactjsbasics/node_modules/webpack/bin/convert-argv.js:487
throw new Error("'output.filename' is required, either in config file or as --output-filename");
^
Error: 'output.filename' is required, either in config file or as --output-filename
at processOptions (/var/www/reactjsbasics/node_modules/webpack/bin/convert-argv.js:487:11)
at processConfiguredOptions (/var/www/reactjsbasics/node_modules/webpack/bin/convert-argv.js:136:4)
at module.exports (/var/www/reactjsbasics/node_modules/webpack/bin/convert-argv.js:112:10)
at Object.<anonymous> (/var/www/reactjsbasics/node_modules/webpack/bin/webpack.js:155:40)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactjsbasics#1.0.0 build: `webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --watch`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactjsbasics#1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
┌──────────────────────────────────────────────────────────┐
│ npm update check failed │
│ Try running with sudo or get access │
│ to the local update config store via │
│ sudo chown -R $USER:$(id -gn $USER) /home/me/.config │
└──────────────────────────────────────────────────────────┘
npm ERR! A complete log of this run can be found in:
npm ERR! /home/me/.npm/_logs/2017-07-18T06_15_33_602Z-debug.log
webpack.config.js
var webpack=require("webpack");
var path=require("path");
var DIST_DIR = path.resolve(__dirname,"dist");
var SRC_DIR = path.resolve(__dirname,"src");
var config={
entry:SRC_DIR + "/app/index.js",
output:{
path:DIST_DIR+"/app",
filename:"bundle.js",
publicPath:"/app/"
},
module:{
loaders:[
{
test:"/\.js?/",
include:SRC_DIR,
loader:"babel-loader",
query:{
presets:["react","es2015","stage-2"]
}
}
]
}
};
package.json
"scripts": {
"start":"npm run build",
"build":"webpack -d && cp src/index.html dist/index.html && webpack-dev-server --content-base src/ --inline --watch",
"build:prod":"webpack -p && cp src/index.html dist/index.html"
},
It looks like you have forgotten to export your config
// webpack.config.js
var config = {
...
};
// you need to export config object
module.exports = config