Encountering a parsing error: Module '@babel/preset-react' cannot be found. Upon creating schema.js, tweetSchema.js, userSchema.js, issues arose with import, export, and export from all three files showing red lines.
schema.js:
import createSchema from 'part:@sanity/base/schema-creator'
import schemaTypes from 'all:part:@sanity/base/schema-type'
import {userSchema} from './userSchema'
import {tweetSchema} from './tweetSchema'
export default createSchema({
name: 'default',
types: schemaTypes.concat([userSchema, tweetSchema]),
})
tweetSchema.js:
export const tweetSchema = {
name: 'tweets',
type: 'document',
title: 'Tweets',
fields: [
{
name: 'tweet',
type: 'string',
title: 'Tweet',
},
],
}
userSchema.js:
export const userSchema = {
name: 'users',
type: 'document',
title: 'Users',
fields: [
{
name: 'coverImage',
type: 'string',
title: 'Cover Image',
},
{
name: 'tweets',
title: 'Tweets',
type: 'array',
of: [
{
type: 'reference',
to: [{type: 'tweets'}],
},
],
},
],
}
Shown below is my package.json file:
{
"name": "twiiter-clone",
"private": true,
"version": "1.0.0",
"main": "package.json",
"license": "UNLICENSED",
"scripts": {
"dev": "sanity dev",
"start": "sanity start",
"build": "sanity build",
"deploy": "sanity deploy",
"deploy-graphql": "sanity graphql deploy"
},
"keywords": ["sanity"],
...
tsconfig.json:
{
"compilerOptions": {
"target": "ES2017",
"lib": ["dom", "dom.iterable", "esnext"],
...
"
Attempts were made to install @babel/preset-react
, unfortunately without success.