Hello,
I have a website with front-end NextJs and back-end WordPress. I deployed the WordPress to WebHost, and I add the URL to .env in NextJS, but when I add this URL and run>npm run build,
I get this error:
./node_modules/node-fetch/lib/index.js
Module not found: Can’t resolve ‘encoding’ in ‘C:\Users\SONY\Local Sites\newbeginnings\app\public\wp-content\themes\new-beginning-next\node_modules\node-fetch\lib’
Build error occurred
Error: Unexpected token < in JSON at position 0
at new ApolloError (C:\Users\SONY\Local Sites\newbeginnings\app\public\wp-content\themes\new-beginning-next.next\serverless\pages[…slug].js:5333:28)
at C:\Users\SONY\Local Sites\newbeginnings\app\public\wp-content\themes\new-beginning-next.next\serverless\pages[…slug].js:50424:19
at C:\Users\SONY\Local Sites\newbeginnings\app\public\wp-content\themes\new-beginning-next.next\serverless\pages[…slug].js:71860:69
at new Promise ()
at Object.error (C:\Users\SONY\Local Sites\newbeginnings\app\public\wp-content\themes\new-beginning-next.next\serverless\pages[…slug].js:71860:21)
at notifySubscription (C:\Users\SONY\Local Sites\newbeginnings\app\public\wp-content\themes\new-beginning-next.next\serverless\pages[…slug].js:70038:18)
at onNotify (C:\Users\SONY\Local Sites\newbeginnings\app\public\wp-content\themes\new-beginning-next.next\serverless\pages[…slug].js:70077:3)
at SubscriptionObserver.error (C:\Users\SONY\Local Sites\newbeginnings\app\public\wp-content\themes\new-beginning-next.next\serverless\pages[…slug].js:70138:7)
at C:\Users\SONY\Local Sites\newbeginnings\app\public\wp-content\themes\new-beginning-next.next\serverless\pages[…slug].js:71848:68
at Array.forEach () {
type: ‘ApolloError’,
graphQLErrors: ,
networkError: {
name: ‘ServerParseError’,
response: { size: 0, timeout: 0 },
statusCode: 404,
bodyText: ‘<!doctype html>\n’ +
‘\n’ +
‘\n’ +
’ \n’ +
'… with the rest of html error page
Am I missing something that should be added?
In package.json the script section is:
“scripts”: {
"build": "next build",
"dev": "next dev",
"start": "next start",
"postbuild": "next-on-netlify",
"export": "next export",
"deploy": "npm run build && npm run export",
"svg": "svgr -d src/components/icons src/components/icons/svgs",
"cypress:open": "cypress open",
"cypress:run": "cypress run --browser chrome"
},
I would appreciate it if anyone could help me deploy this website.
Thanks in advance