Next.js example takes a long time to compile due to Inter google fonts - next.js

I'm trying with the trivial next.js example blog from their tutorial. However, when I access the page, I get the following situation:
$ npm run dev
> nextjs-blog#0.1.0 dev /Users/<redacted>/tmp/nextjs-blog
> next dev
ready - started server on 0.0.0.0:3000, URL: http://localhost:3000
event - compiled client and server successfully in 386 ms (165 modules)
wait - compiling /_error (client and server)...
event - compiled client and server successfully in 91 ms (166 modules)
warn - Fast Refresh had to perform a full reload due to a runtime error.
wait - compiling / (client and server)...
error - Failed to download `Inter` from Google Fonts. Using fallback font instead.
event - compiled client and server successfully in 152.9s (195 modules)
error - Failed to download `Inter` from Google Fonts. Using fallback font instead.
warn - Fast Refresh had to perform a full reload due to a runtime error.
I am not sure why it hangs for two minutes and why it can't download the google fonts. I am behind a proxy, so I suspect that could be a factor, but I cannot find anything on how to set up a proxy for next.js in the configuration (assuming the actual problem is that).
Note that HTTP_PROXY and HTTPS_PROXY are set correctly.
I'm running with these:
"next": "13.0.7"
npx create-next-app#latest nextjs-blog --use-npm --example
GitHub Link
I tried as suggested to run npm run build, and I get the following:
$ npm run build
> nextjs-blog#0.1.0 build /Users/xxx/tmp/nextjs-blog
> next build
info - Linting and checking validity of types
info - Creating an optimized production build
Failed to compile.
pages/index.tsx
`#next/font` error:
Failed to fetch `Inter` from Google Fonts.
> Build failed because of webpack errors
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nextjs-blog#0.1.0 build: `next build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nextjs-blog#0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
The logs file does not give more info than this.

Same issue, I suspect it's because #next/font doesn't respect HTTPS_PROXY
environment variable. It's really frustrating for a new user (behind a proxy) who read the fantastic docs but cannot even run a minimal create-next-app project (at least the default index.js).

I Disconnected with the VPN and it solved this problem.

some solutions
solution 1
just remove the #next/font/google module, if you don't need it.
import Head from 'next/head'
import Image from 'next/image'
- import { Inter } from '#next/font/google'
import styles from '#/styles/Home.module.css'
- const inter = Inter({ subsets: ['latin'] })
solution 2
if you are using a VPN, quit your VPN and try it again.
As #ashwani-panwar suggested.
It works for me.
refs
https://github.com/vercel/next.js/discussions/46012

I had this same issue, but I wasn't behind a proxy, after a lot of code testing I discovered the fault was from #next/font/google, it stuck on compiling /page and didn't show an error. A temporary solution I found is to use a VPN service to change your IP address, there seems to be a network request issue when Next gets the fonts from the server.
Update
visiting https://fonts.google.com seems to indicate whether the issue is from Google's servers or something else, if #next/font/google is causing a slowdown visiting the fonts page ussually hangs too.

Related

Using Azure static web app with a Quasar Project

I thought it would be pretty simple to host a vuejs quasar project in azure static web apps but I cannot even seem to do the build process from github to publish the website. I can do quasar dev and quasar serve locally and all works great. It is just the assets do not seem to load and trigger a build error for pushing to github/azure. My error comes out as follows:
[vite:asset] Could not load /github/workspace/src/assets/imgs/12.jpg (imported by src/components/HomeRecentWork.vue): ENOENT: no such file or directory, open '/github/workspace/src/assets/imgs/12.jpg'
node:internal/process/promises:288
triggerUncaughtException(err, true /* fromPromise */);
^
[Error: Could not load /github/workspace/src/assets/imgs/12.jpg (imported by src/components/HomeRecentWork.vue): ENOENT: no such file or directory, open '/github/workspace/src/assets/imgs/12.jpg'] {
errno: -2,
code: 'PLUGIN_ERROR',
syscall: 'open',
path: '/github/workspace/src/assets/imgs/12.jpg',
pluginCode: 'ENOENT',
plugin: 'vite:asset',
hook: 'load',
watchFiles: [
'/github/workspace/index.html',
'/github/workspace/.quasar/client-entry.js',
'/github/workspace/node_modules/vite/package.json',
'/github/workspace/node_modules/vue/package.json',
'/github/workspace/node_modules/#quasar/extras/package.json',
'/github/workspace/node_modules/quasar/package.json',
'/github/workspace/node_modules/vue/dist/vue.runtime.esm-bundler.js',
'/github/workspace/node_modules/#quasar/extras/fontawesome-v6/fontawesome-v6.css',
'/github/workspace/node_modules/#quasar/extras/roboto-font/roboto-font.css',
'/github/workspace/node_modules/#quasar/extras/material-icons/material-icons.css',
'/github/workspace/node_modules/quasar/dist/quasar.sass',
'/github/workspace/.quasar/app.js',
'/github/workspace/.quasar/quasar-user-options.js',
'/github/workspace/src/css/app.scss',
'/github/workspace/src/boot/axios.js',
'vite/preload-helper',
'/github/workspace/node_modules/#vue/runtime-dom/package.json',
'/github/workspace/node_modules/#vue/runtime-dom/dist/runtime-dom.esm-bundler.js',
'/github/workspace/node_modules/quasar/src/vue-plugin.js',
'/github/workspace/src/App.vue',
'/github/workspace/src/stores/index.js',
'/github/workspace/src/router/index.js',
'/github/workspace/node_modules/quasar/src/plugins/Meta.js',
'/github/workspace/node_modules/quasar/src/plugins/Notify.js',
'/github/workspace/node_modules/axios/package.json',
'/github/workspace/node_modules/quasar/wrappers/index.mjs',
'/github/workspace/node_modules/axios/index.js',
'/github/workspace/node_modules/#vue/runtime-core/package.json',
'/github/workspace/node_modules/#vue/shared/package.json',
'/github/workspace/node_modules/#vue/runtime-core/dist/runtime-core.esm-bundler.js',
'/github/workspace/node_modules/#vue/shared/dist/shared.esm-bundler.js',
'/github/workspace/node_modules/quasar/src/install-quasar.js',
'/github/workspace/node_modules/quasar/src/lang.js',
'/github/workspace/node_modules/quasar/src/icon-set.js',
'plugin-vue:export-helper',
'/github/workspace/node_modules/pinia/package.json',
'/github/workspace/node_modules/pinia/dist/pinia.mjs',
'/github/workspace/node_modules/vue-router/package.json',
'/github/workspace/node_modules/vue-router/dist/vue-router.mjs',
'/github/workspace/src/router/routes.js',
'/github/workspace/node_modules/quasar/src/plugins/Platform.js',
'/github/workspace/node_modules/quasar/src/utils/extend.js',
'/github/workspace/node_modules/quasar/src/components/avatar/QAvatar.js',
'/github/workspace/node_modules/quasar/src/components/icon/QIcon.js',
'/github/workspace/node_modules/quasar/src/components/btn/QBtn.js',
'/github/workspace/node_modules/quasar/src/components/spinner/QSpinner.js',
'/github/workspace/node_modules/quasar/src/utils/private/create.js',
'/github/workspace/node_modules/quasar/src/utils/event.js',
'/github/workspace/node_modules/quasar/src/utils/private/global-nodes.js',
'/github/workspace/node_modules/quasar/src/utils/is.js',
'\x00commonjsHelpers.js',
'/github/workspace/node_modules/axios/lib/axios.js',
'\x00/github/workspace/node_modules/axios/lib/axios.js?commonjs-proxy',
'/github/workspace/node_modules/#vue/reactivity/package.json',
'/github/workspace/node_modules/#vue/reactivity/dist/reactivity.esm-bundler.js',
'/github/workspace/node_modules/quasar/src/plugins/Screen.js',
'/github/workspace/node_modules/quasar/src/plugins/Dark.js',
'/github/workspace/node_modules/quasar/src/history.js',
'/github/workspace/node_modules/quasar/src/body.js',
'/github/workspace/node_modules/quasar/src/utils/private/symbols.js',
'/github/workspace/node_modules/quasar/src/utils/private/global-config.js',
'/github/workspace/node_modules/quasar/src/utils/private/define-reactive-plugin.js',
'/github/workspace/node_modules/quasar/lang/en-US.mjs',
'/github/workspace/node_modules/quasar/src/utils/private/inject-obj-prop.js',
'/github/workspace/node_modules/quasar/icon-set/material-icons.mjs',
'/github/workspace/node_modules/vue-demi/package.json',
'/github/workspace/node_modules/#vue/devtools-api/package.json',
'/github/workspace/node_modules/vue-demi/lib/index.mjs',
'/github/workspace/node_modules/#vue/devtools-api/lib/esm/index.js',
'/github/workspace/src/layouts/MainLayout.vue',
'/github/workspace/src/pages/IndexPage.vue',
'/github/workspace/src/pages/ErrorNotFound.vue',
'/github/workspace/node_modules/quasar/src/composables/private/use-size.js',
'/github/workspace/node_modules/quasar/src/utils/private/render.js',
'/github/workspace/node_modules/quasar/src/directives/Ripple.js',
'/github/workspace/node_modules/quasar/src/components/btn/use-btn.js',
'/github/workspace/node_modules/quasar/src/utils/private/key-composition.js',
'/github/workspace/node_modules/quasar/src/components/spinner/use-spinner.js',
'\x00/github/workspace/node_modules/axios/lib/axios.js?commonjs-module',
'/github/workspace/node_modules/axios/lib/utils.js',
'\x00/github/workspace/node_modules/axios/lib/utils.js?commonjs-proxy',
'/github/workspace/node_modules/axios/lib/helpers/bind.js',
'\x00/github/workspace/node_modules/axios/lib/helpers/bind.js?commonjs-proxy',
'/github/workspace/node_modules/axios/lib/core/Axios.js',
'\x00/github/workspace/node_modules/axios/lib/core/Axios.js?commonjs-proxy',
'/github/workspace/node_modules/axios/lib/core/mergeConfig.js',
'\x00/github/workspace/node_modules/axios/lib/core/mergeConfig.js?commonjs-proxy',
'/github/workspace/node_modules/axios/lib/defaults.js',
'\x00/github/workspace/node_modules/axios/lib/defaults.js?commonjs-proxy',
'/github/workspace/node_modules/axios/lib/cancel/Cancel.js',
'\x00/github/workspace/node_modules/axios/lib/cancel/Cancel.js?commonjs-proxy',
'/github/workspace/node_modules/axios/lib/cancel/CancelToken.js',
'\x00/github/workspace/node_modules/axios/lib/cancel/CancelToken.js?commonjs-proxy',
'/github/workspace/node_modules/axios/lib/cancel/isCancel.js',
'\x00/github/workspace/node_modules/axios/lib/cancel/isCancel.js?commonjs-proxy',
'/github/workspace/node_modules/axios/lib/helpers/spread.js',
'\x00/github/workspace/node_modules/axios/lib/helpers/spread.js?commonjs-proxy',
'/github/workspace/node_modules/axios/lib/helpers/isAxiosError.js',
'\x00/github/workspace/node_modules/axios/lib/helpers/isAxiosError.js?commonjs-proxy',
'/github/workspace/node_modules/quasar/src/utils/debounce.js',
... 128 more items
]
}
Node.js v18.12.1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
---End of Oryx build logs---
Oryx has failed to build the solution.
I have not found much info on doing a quasar project inside azure web apps so any advice would be helpful. All the tutorials I have found and gone through do not have these issues and I really do not have a complicated project that deviates from the standard quasar project.
EDIT:
the issue is actually my image paths. I am using with src="~assets/imgs/embroidery.jpg" where ~ must be an alias setup in quasar. Works for components in quasar but not for raw img tags. If i use a relative path like ../assets/imgs/filename.jpg it still draws an error on build. However, if i do /assets/imgs/filename.jpg and put the assets folder in public it works. I dont want to do this however so how should i put the paths for images in my components if not a vue-component per say?

Vague error in Vercel deployment (exit with code 1)

So normally Vercel gives me decent error messages, but this one seems to have no detail. Just
"failed with exit code 1".
For context, I just started this project w the basic NextJS template, made a few modifications, and this is my first deploy.
Failed once and I assumed it was because NextJS has strict type checking on by default, so I modified the next.config.js file as follows (per here):
module.exports = {
typescript: {
// !! WARN !!
// Dangerously allow production builds to successfully complete even if
// your project has type errors.
// !! WARN !!
ignoreBuildErrors: true,
},
};
But still failed. Here is the full log:
10:23:27.575 Cloning github.com/lawderp/physical (Branch: main, Commit: 8f97554)
10:23:28.589 Cloning completed: 1.014s
10:23:28.614 Analyzing source code...
10:23:29.739 Installing build runtime...
10:23:31.612 Build runtime installed: 1.873s
10:23:34.043 Looking up build cache...
10:23:34.164 Build cache found. Downloading...
10:23:35.100 Build cache downloaded [21.48 MB]: 936.007ms
10:23:36.250 Installing dependencies...
10:23:36.489 yarn install v1.22.11
10:23:36.547 [1/4] Resolving packages...
10:23:36.734 success Already up-to-date.
10:23:36.743 Done in 0.26s.
10:23:36.754 Detected Next.js version: 11.1.2
10:23:36.755 Running "yarn run build"
10:23:37.021 yarn run v1.22.11
10:23:37.047 $ next build
10:23:37.820 info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
10:23:37.976 info - Skipping validation of types...
10:23:40.439 error Command failed with exit code 1.
10:23:40.439 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
10:23:40.456 Error: Command "yarn run build" exited with 1
Still not sure what the issue was but eventually figured out how to get past this - ignored ESLint during build by adding the following to next.config.js:
eslint: {
ignoreDuringBuilds: true,
},
(I don't advise doing this but this was quick low-stakes experiment)
I received the same vague message after making eslint alterations. Locally linting and deployment was successful, however deploying to vercel failed like yours.
Although "ignoreDuringBuilds": "true" in my .eslint.json did band-aid fix the issue, I was able to rollback each eslint change and found that my "linebreak-style": ["error", "windows"] was the underlying issue.
It passed linting locally, but failed on vercel deployment. I've fixed my line-breaks and all works great now without having to ignore during builds.

create-next-app does not work, get internal server error

Need some advice on this. I have initialize a whole new project by using create-next-app:
npx create-next-app nextjs-app
I was able to start the project by calling npm run dev. This is what i have in the terminal when run on the development server:
ready - started server on http://localhost:3000
However, i get internal server error when navigate to localhost:3000. There is this error on the terminal:
Error: Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:
1. You might have mismatching versions of React and the renderer (such as React DOM)
2. You might be breaking the Rules of Hooks
3. You might have more than one copy of React in the same app
I am running on node v12.16.3 and npm v6.14.4

Why can't I load js and css when using hexo publish blog

I want to use hexo to public my blog on github.I can get my webpage using localhost:4000 but after deployed to github.I can only get page with words but js and css can't be loaded.
here is the error message from chrome console
http://rudy-zhang.github.io/css/style.css Failed to load resource: the server responded with a status of 404 (Not Found)
There is no content in css file but I can find content in the files of repository.
When I install hexo I get warning
> $ npm install hexo -g
npm WARN optional dep failed, continuing fsevents#0.3.5
|
> dtrace-provider#0.4.0 install C:\Users\Rudy\AppData\Roaming\npm\node_modules\h
exo\node_modules\bunyan\node_modules\dtrace-provider
> node scripts/install.js npm WARN optional dep failed, continuing fsevents#0.3.0
I'm not familiar with nodejs so I don't know if it's the place something wrong.
How can I fix this problem?
Maybe hexo2.8 is a good choose.
I had the same problem,cause I changed the themes's css style.And then I back to hexo2.8,the problem missing.
npm install hexo#2.8 -g

npm behind a proxy fails with status 403

I'm trying to run npm behind a proxy. I've tried both entering the proxy directly or through Authoxy:
npm config set proxy http://localhost:8999
npm config set https-proxy http://localhost:8999
Regardless of which proxy I use, I always end up with the same error when running npm search:
npm info it worked if it ends with ok
npm verb cli [ 'node', '/usr/local/bin/npm', 'search' ]
npm info using npm#1.1.45
npm info using node#v0.8.4
npm verb config file /Users/xxx/.npmrc
npm verb config file /usr/local/etc/npmrc
npm verb config file /usr/local/lib/node_modules/npm/npmrc
npm WARN Building the local index for the first time, please be patient
npm verb url raw /-/all
npm verb url resolving [ 'https://registry.npmjs.org/', './-/all' ]
npm verb url resolved https://registry.npmjs.org/-/all
npm info retry registry request attempt 1 at 09:48:47
npm http GET https://registry.npmjs.org/-/all
npm info retry will retry, error on last attempt: Error: tunneling socket could not be established, sutatusCode=403
npm info retry registry request attempt 2 at 09:48:57
npm http GET https://registry.npmjs.org/-/all
npm info retry will retry, error on last attempt: Error: tunneling socket could not be established, sutatusCode=403
npm info retry registry request attempt 3 at 09:49:57
npm http GET https://registry.npmjs.org/-/all
npm ERR! Error: tunneling socket could not be established, sutatusCode=403
npm ERR! at ClientRequest.onConnect (/usr/local/lib/node_modules/npm/node_modules/request/tunnel.js:148:19)
npm ERR! at ClientRequest.g (events.js:185:14)
npm ERR! at ClientRequest.EventEmitter.emit (events.js:115:20)
npm ERR! at Socket.socketOnData (http.js:1383:11)
npm ERR! at TCP.onread (net.js:410:27)
The command always fails with sutatusCode [sic!] 403 - which means unauthorized. I have set up Authoxy to not require a username/password. The same error happens when I bypass Authoxy and provide the real proxy credentials for our NTLM proxy in the form of http:// user:pass#proxy:port.
How can I make this work through the proxy?
Update
I have created an issue on the NPM project to report this: https://github.com/isaacs/npm/issues/2866
OK, so within minutes after posting the question, I found the answer myself here:
https://github.com/npm/npm/issues/2119#issuecomment-5321857
The issue seems to be that npm is not that great with HTTPS over a proxy. Changing the registry URL from HTTPS to HTTP fixed it for me:
npm config set registry http://registry.npmjs.org/
I still have to provide the proxy config (through Authoxy in my case), but everything works fine now.
Seems to be a common issue, but not well documented. I hope this answer here will make it easier for people to find if they run into this issue.
npm config set proxy http://proxy.company.com:8080
npm config set https-proxy http://proxy.company.com:8080
credit goes to http://jjasonclark.com/how-to-setup-node-behind-web-proxy.
If you need to provide a username and password to authenticate at your proxy, this is the syntax to use:
npm config set proxy http://usr:pwd#host:port
npm config set https-proxy http://usr:pwd#host:port
If anyone else ends up breaking their proxy config settings go to your .npmrc, to type in the settings. This file is located at your node root folder level.
Here's whats my corrected file looks like:
#proxy = http://proxy.company.com:8080
https-proxy = https://proxy.company.com:8080
registry = http://registry.npmjs.org/
In my case, I read the registry that npm using:
npm config get registry
and I got
http://registry.npmjs.org/
then I had just changed http to https like this:
npm config set registry https://registry.npmjs.org/
Due to security violations, organizations may have their own repositories.
set your local repo as below.
npm config set registry https://yourorg-artifactory.com/
I hope this will solve the issue.
For those using Jenkins or other CI server: it matters where you define your proxies, especially when they're different in your local development environment and the CI environment. In this case:
don't define proxies in project's .npmrc file. Or if you do, be sure to override the settings on CI server.
any other proxy settings might cause 403 Forbidden with little hint to the fact that you're using the wrong proxy. Check your gradle.properties or such and fix/override as necessary.
TLDR: define proxies not in the project but on the machine you're working on.
On windows 10, do
npm config edit
This will open config file in a text editor. Delete all the set proxy variables by user and only let default values stay.
;;;;
; npm userconfig file
; this is a simple ini-formatted file
; lines that start with semi-colons are comments.
; read `npm help config` for help on the various options
;;;;
--->Delete everything proxy settings from here.
;;;;
; all options with default values
;;;;
Close and save. Try again. That's what worked for me in my localhost.
I had the same issue and finally it was resolved by disconnecting from all VPN .
On windows10, create this file. Worked for me.
my personal access token expired recently. I generated a new one, and replaced the old in .zshrc.
Encountered same error as above when ran yarn install.
Authorizing token with SSO fixed it for me.

Resources