Reputation: 85
I'm facing this error while trying to run next.js in dev mode. I have no idea why this is happening thought I am not even using electron in this application.
Error was not caught TypeError: Cannot use 'in' operator to search for 'electron' in undefined at next-dev.js:8
This is my next.config
const withTM = require('next-transpile-modules')(['@my-storybook'])
const watchStorybook = require('@my-storybook/watch-storybook');
const webpack = require('webpack');
const ENV = require('./config/environments/environment')
let GPA_ENV;
switch (process.env.API_URL_BASE) {
case 'https://my-api':
GPA_ENV = 'k15'
break;
case 'https://my-api2':
GPA_ENV = 'development'
break;
default:
GPA_ENV = 'homolog'
}
module.exports = withTM({
webpack: (config, { dev }) => {
if(dev) watchStorybook();
config.plugins.push(
new webpack.DefinePlugin({
process: {
env: {
GPA_ENV : JSON.stringify(GPA_ENV)
}
}
})
)
return config
},
publicRuntimeConfig: {
API_URL_BASE: process.env.API_URL_BASE || ENV.URLS.API_URL_BASE || 'https://my-api3',
IMAGE_URL_BASE: process.env.IMAGE_URL_BASE || ENV.URLS.IMAGE_URL_BASE || 'https://my-api',
STOMP_URL_BASE: process.env.STOMP_URL_BASE || 'https://my-websocket',
STOMP_RECONNECT_DELAY: process.env.STOMP_RECONNECT_DELAY || '10000',
SECURE_COOKIES: process.env.SECURE_COOKIES || '0',
ROBOTS_NOINDEX: process.env.ROBOTS_NOINDEX || '0',
SITE_URL_BASE: process.env.SITE_URL_BASE || 'https://my-api',
GPA_ENV: GPA_ENV,
USE_INTELIPOST: !!Number(process.env.USE_INTELIPOST),
},
})
and here is my package.json
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"create-component": "node config/scripts/create-component",
"create-page": "node config/scripts/create-page",
"pa:dev": "npm run env:pa:dev && npm run dev",
"pa:hlg": "npm run env:pa:hlg && npm run dev",
"adega:dev": "npm run env:adega:dev && npm run dev",
"adega:hlg": "npm run env:adega:hlg && npm run dev",
"adega:stage": "npm run env:adega:stage && npm run dev",
"ex:dev": "npm run env:ex:dev && npm run dev",
"ex:hlg": "npm run env:ex:hlg && npm run dev",
"env:pa:dev": "node ./node_modules/app-json-env-gen/cli.js dir=./__env__/pa target=dev output=./config/environments/environment.js",
"env:adega:dev": "node ./node_modules/app-json-env-gen/cli.js dir=./__env__/adega target=dev output=./config/environments/environment.js",
"env:ex:dev": "node ./node_modules/app-json-env-gen/cli.js dir=./__env__/ex target=dev output=./config/environments/environment.js",
"env:pa:hlg": "node ./node_modules/app-json-env-gen/cli.js dir=./__env__/pa target=hlg output=./config/environments/environment.js",
"env:adega:hlg": "node ./node_modules/app-json-env-gen/cli.js dir=./__env__/adega target=hlg output=./config/environments/environment.js",
"env:ex:hlg": "node ./node_modules/app-json-env-gen/cli.js dir=./__env__/ex target=hlg output=./config/environments/environment.js",
"env:pa:prd": "node ./node_modules/app-json-env-gen/cli.js dir=./__env__/pa target=prd output=./config/environments/environment.js",
"env:adega:prod": "node ./node_modules/app-json-env-gen/cli.js dir=./__env__/adega target=prd output=./config/environments/environment.js",
"env:adega:stage": "node ./node_modules/app-json-env-gen/cli.js dir=./__env__/adega target=prd output=./config/environments/environment.js",
"env:ex:prd": "node ./node_modules/app-json-env-gen/cli.js dir=./__env__/ex target=prd output=./config/environments/environment.js"
},
"dependencies": {
"@my-storybook": "1.0.1-7",
"@material-ui/core": "^4.9.13",
"@material-ui/icons": "^4.9.1",
"@material-ui/styles": "^4.9.13",
"@zeit/next-sass": "^1.0.1",
"next": "9.3.6",
"next-transpile-modules": "^3.3.0",
"node-sass": "^4.14.0",
"react": "16.13.1",
"react-dom": "16.13.1",
"redux-saga": "^1.1.3",
"webpack": "^4.43.0"
},
"devDependencies": {
"@types/node": "^13.13.4",
"@types/react": "^16.9.34",
"app-json-env-gen": "^0.6.0",
"tslint": "6.1.2",
"tslint-config-airbnb": "5.11.2",
"tslint-react": "5.0.0",
"typescript": "^3.8.3"
}
}
I've tryed:
to remove node_modules and package-lock, with no success.
Search for electron
in my app, but there is not such word, only in next.js node_modules files.
I don't know what more I should do.
Can anyone give some light on this?? Thanks people, you are awesome!
Upvotes: 1
Views: 4829
Reputation: 11
I didn't try to understand why it happens but it can be fixed by simply adding
if (typeof process.versions === 'undefined') process.versions = {};
to your /pages/_app.js
file.
Upvotes: 1