next.js: Module parse failed: Unexpected token (2:4) 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
Bug report
I have been following the exact steps for starting a Next.js app here: https://nextjs.org/learn/basics/getting-started/setup
I also followed the steps for starting a next.js app on Shopify (I want to develop an app there).
I have worked heavily with react but never with next. When I go running the npm run dev command I keep getting the following error:
Module parse failed: Unexpected token (2:4)
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 Index = () => (
> <div>
| <p>Hello Next.js</p>
| </div>
[ event ] build page: /next/dist/pages/_error
[ wait ] compiling ...
[ error ] D:/webDev/shopifyApps/hello-next/pages/index.js 2:4
Module parse failed: Unexpected token (2:4)
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 Index = () => (
> <div>
| <p>Hello Next.js</p>
| </div>
ModuleParseError: Module parse failed: Unexpected token (2:4)
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 Index = () => (
> <div>
| <p>Hello Next.js</p>
| </div>
at handleParseError (D:\webDev\shopifyApps\hello-next\node_modules\webpack\lib\NormalModule.js:461:19)
at doBuild.err (D:\webDev\shopifyApps\hello-next\node_modules\webpack\lib\NormalModule.js:495:5)
at runLoaders (D:\webDev\shopifyApps\hello-next\node_modules\webpack\lib\NormalModule.js:354:12)
at D:\webDev\shopifyApps\hello-next\node_modules\loader-runner\lib\LoaderRunner.js:373:3
at iterateNormalLoaders (D:\webDev\shopifyApps\hello-next\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
at D:\webDev\shopifyApps\hello-next\node_modules\loader-runner\lib\LoaderRunner.js:205:4
at process.nextTick (D:\webDev\shopifyApps\hello-next\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:85:15)
at processTicksAndRejections (internal/process/next_tick.js:74:9)
[ event ] client pings, but there's no entry for page: /_error
[ event ] disposing inactive page(s): /, /next/dist/pages/_error
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 4
- Comments: 23 (5 by maintainers)
This happened to me because I was importing shared JSX code from outside of my nextjs app’s directory from elsewhere in my mono repo. This was my solution: https://github.com/zeit/next.js/issues/706#issuecomment-569041997
Oh my god 🤦♂️ Thanks past myself. You helped me again!
In my case it is failing with the same error because I run the project from
C:\repos\projectname, butC:\reposis a directory junction toC:\Users\Qwerty\repos. When I runnpm run devfrom the original directory, it worked.This is rather a pain, but at least it works.
I’m getting this error, too. I’m trying to set up npx create-next-app but i always see this error. How can i fix this?
Excuse me. I’m following the same guide, and came into the same problem. I don’t understand how I can overcame this problem, what is the answer to this problem? I repeated everything but the problem repeated.
@kylerRenneker you don’t need a
.babelrcin your project, right. But he means that perhaps you have a.babelrcfile up in your directory tree, maybe atD:\webDev\shopifyAppsorD:\webDev\and so on, that is being utilized and is compiling the project incorrectly. I am running your example and it is working fine.Well, I wish I had more to add than this…but it spontaneously started working.
I deleted the old project folder and started from scratch following the same steps as before and now the project is running.