为什么我在下一个nextjs步骤上出错

时间:2018-09-27 22:14:26

标签: node.js next.js

因此,我只是遵循这些指南,即这些家伙都是nextjs.org的,这似乎还不错。 https://nextjs.org/learn/basics/getting-started/setup

当我到达终点时[仅需几个基本步骤]

npm run dev

我立即收到一个讨厌的错误:

hello-next npm run dev

> hello-next@1.0.0 dev /Users/myuser/Projects/ssr/hello-next
> next

/Users/myuser/Projects/ssr/hello-next/node_modules/hard-source-    webpack-plugin/index.js:106
}
^
SyntaxError: Unexpected token }
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/myuser/Projects/ssr/hello-next/node_modules/next/dist/build/webpack.js:64:55)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! hello-next@1.0.0 dev: `next`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the hello-next@1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/myuser/.npm/_logs/2018-09-27T22_05_37_582Z-debug.log

这必须在我的系统中,但是我想知道是什么。我在笔记本电脑上尝试过,它也在那里发生过。

我转到了这个文件,看起来很正常,位于node_modules / hard-source-webpack-plugin / index.js:

function contextNormalLoaders(compiler, loaders) {
  return loaders.map(loader =>
    Object.assign({}, loader, {
      loader: contextNormalPath(compiler, loader.loader),
    }),
  );
}

我环顾四周,看看是否有人遇到此错误,却什么也没发现。想法?

1 个答案:

答案 0 :(得分:0)

在我将其发布到nextjs github页面后,此问题被其他人解决。我基本上有一个旧的节点版本。

参考:https://github.com/zeit/next.js/issues/5325