SyntaxError: Cannot use import statement outside a module at \node_modules\next-slicezone\index.js:1
See original GitHub issueVersion
- Prismic CLI version: 3.8.13
Reproduction
Added slicezone per documentation.
What is expected?
Using slicezone after install
What is actually happening?
C:\Users\jrhag\react-sites\edit-elements\node_modules\next-slicezone\index.js:1
import React from 'react'
^^^^^^
SyntaxError: Cannot use import statement outside a module
at compileFunction (<anonymous>)
at wrapSafe (internal/modules/cjs/loader.js:984:16)
at Module._compile (internal/modules/cjs/loader.js:1032:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.next-slicezone (C:\Users\jrhag\react-sites\edit-elements\.next\server\pages\shop\[category]\[uid].js:152:18)
at __webpack_require__ (C:\Users\jrhag\react-sites\edit-elements\.next\server\webpack-runtime.js:25:42)
at Object../pages/shop/[category]/[uid].js (C:\Users\jrhag\react-sites\edit-elements\.next\server\pages\shop\[category]\[uid].js:26:72)
at __webpack_require__ (C:\Users\jrhag\react-sites\edit-elements\.next\server\webpack-runtime.js:25:42)
at __webpack_exec__ (C:\Users\jrhag\react-sites\edit-elements\.next\server\pages\shop\[category]\[uid].js:195:52)
at C:\Users\jrhag\react-sites\edit-elements\.next\server\pages\shop\[category]\[uid].js:196:28
at Object.<anonymous> (C:\Users\jrhag\react-sites\edit-elements\.next\server\pages\shop\[category]\[uid].js:199:3)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
wait - compiling...
error - ./node_modules/next-slicezone/index.js
Module parse failed: Unexpected token (6:2)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
| const PageInfo = ({ title, description }) => (
> <div
| style={{
| height: '80vh',
Any additional information
Everything else from Prismic works fine. I did have to consult Prismic because I was migrating to an existing repo, and I had to redo some config files, but everything looks as it should (from my estimate). Please let me know what/where I should be looking for to troubleshoot. Thanks!
One of the pages (that I made as a test) that is causing the error:
import { client } from '../../../prismic-configuration'
import Prismic from '@prismicio/client'
import { SliceZone } from 'next-slicezone'
import { useGetStaticProps, useGetStaticPaths} from 'next-slicezone/hooks'
import resolver from '../../../sm-resolver'
const CategoryProduct = ({slices}) => {
return(
<div>
</div>
)
}
export async function getStaticProps(props) {
const { params: { uid, category }} = props
console.log(uid, category)
const products = await client.query([
Prismic.Predicates.at('', 'product'),
])
const prods = {
props: {
products
}
}
return prods
}
export async function getStaticPaths() {
const results = {
paths: [
{
params: {
uid: 'handmade-film-transitions',
category: 'transitions'
}
}
], fallback: false
}
return results
}
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:9 (1 by maintainers)
Top Results From Across the Web
SyntaxError: Cannot use import statement outside a module
Verify that you have the latest version of Node.js installed (or, at least 13.2.0+). Then do one of the following, as described in...
Read more >JS Fix For "SyntaxError: Cannot Use Import Statement Outside ...
"SyntaxError: Cannot use import statement outside a module" is a common Node.js error when working with import to include modules or ...
Read more >Cannot use import statement outside a module [React ...
When building a web application, you may encounter the SyntaxError: Cannot use import statement outside a module error.
Read more >How to solve: cannot use import statement outside a module
When you see the error message Uncaught SyntaxError: cannot use import statement outside a module, it means you're using an import statement ......
Read more >SyntaxError: Cannot use import statement outside a module ...
When you use ECMAScript Modules in Node (v13.6.0 for me) combined with Jest, the following error occurs: SyntaxError: Cannot use import ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@hypervillain Working in 0.1.2 - thanks!
I have the exact same issue