-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERR_UNSUPPORTED_ESM_URL_SCHEME error on build #704
Comments
Same hereee |
Yes, there seems to be an error on the As a workaround, I suggest commenting out the Add the following script to import { writeFileSync } from 'fs'
import GithubSlugger from 'github-slugger'
import { allCoreContent, sortPosts } from 'pliny/utils/contentlayer.js'
import { allBlogs } from '../.contentlayer/generated/index.mjs'
import siteMetadata from '../data/siteMetadata.js'
const isProduction = process.env.NODE_ENV === 'production'
/**
* Count the occurrences of all tags across blog posts and write to json file
*/
export async function createTagCount() {
const tagCount = {}
allBlogs.forEach((file) => {
if (file.tags && (!isProduction || file.draft !== true)) {
file.tags.forEach((tag) => {
const formattedTag = GithubSlugger.slug(tag)
if (formattedTag in tagCount) {
tagCount[formattedTag] += 1
} else {
tagCount[formattedTag] = 1
}
})
}
})
writeFileSync('./app/tag-data.json', JSON.stringify(tagCount))
}
export async function createSearchIndex() {
if (
siteMetadata?.search?.provider === 'kbar' &&
siteMetadata.search.kbarConfig.searchDocumentsPath
) {
writeFileSync(
`public/${siteMetadata.search.kbarConfig.searchDocumentsPath}`,
JSON.stringify(allCoreContent(sortPosts(allBlogs)))
)
console.log('Local search index generated...')
}
}
async function postContentlayer() {
await createTagCount()
await createSearchIndex()
}
postContentlayer() You can then run |
I made a PR contentlayerdev/contentlayer#571 to fix this. before new version of make a chagne in +import * as URL from "url"
const successCallback = (onSuccess) => {
if (!onSuccess)
return T.unit;
- return pipe(getCwd, T.map((cwd) => ArtifactsDir.getDirPath({ cwd })), T.tapSync((path) => console.log('successCallback', path)), T.chain((generatedPkgPath) => T.tryCatchPromise(() => onSuccess(() => import(filePathJoin(generatedPkgPath, 'generated', 'index.mjs'))), (error) => new SuccessCallbackError({ error }))), OT.withSpan('@contentlayer/core/generation:successCallback'));
+ return pipe(getCwd, T.map((cwd) => ArtifactsDir.getDirPath({ cwd })), T.tapSync((path) => console.log('successCallback', path)),
+ T.chain((generatedPkgPath) => T.tryCatchPromise(() => onSuccess(() => import(
+ URL.pathToFileURL(
+ filePathJoin(generatedPkgPath, 'generated', 'index.mjs')))
+ )
+ ,
+ (error) => new SuccessCallbackError({ error }))), OT.withSpan('@contentlayer/core/generation:successCallback'));
}; |
Nice workaround, thanks |
This solved my problem,Thanks |
Describe the bug
The site runs ok locally
npm run dev
, but raise errors whennpm run build
.To Reproduce
Steps to reproduce the behavior:
Expected behavior
Build without errors.
System Info (if dev / build issue):
The text was updated successfully, but these errors were encountered: