next.js: Unexpected identifier on next@canary
I’m upgrading a next app to use v8 canary for serverless target. I wasn’t able to get next working on now before this. However, when I’m running my app locally I’m getting this error:
SyntaxError: Unexpected identifier
at new Script (vm.js:74:7)
at createScript (vm.js:246:10)
at Object.runInThisContext (vm.js:298:10)
at Module._compile (internal/modules/cjs/loader.js:657:28)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/Users/anthonyshort/dev/github.com/bridge/app/dashboard/node_modules/next/router.js:1:80)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
/Users/anthonyshort/dev/github.com/bridge/app/dashboard/node_modules/next/dist/client/router.js:2
import _Router from 'next-server/dist/lib/router/router';
This error goes away when I revert back to v7.
To Reproduce
next.config.js looks roughly like this:
module.exports = {
assetPrefix: isProd ? '/dashboard' : '',
publicRuntimeConfig: config[process.env.NODE_ENV],
target: 'serverless'
}
babelrc
{
"presets": ["next/babel", "@babel/preset-flow"],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
[
"styled-components",
{
"ssr": true,
"displayName": false
}
],
[
"module-resolver",
{
"root": ["./"],
"alias": {
"@": "./"
}
}
]
],
"env": {
"test": {
"presets": [
[
"next/babel",
{
"preset-env": {
"modules": "commonjs"
}
}
],
"@babel/preset-flow"
]
}
}
}
package.json
{
"scripts": {
"start": "next start",
"dev": "next",
"build": "next build",
},
"dependencies": {
"@babel/runtime": "^7.1.5",
"apollo-cache-inmemory": "^1.3.0-beta.6",
"apollo-client": "^2.3.7",
"apollo-link-context": "^1.0.7",
"apollo-link-http": "^1.3.2",
"array-move": "^1.0.0",
"autosize": "^4.0.2",
"autosize-input": "^1.0.0",
"classnames": "^2.2.5",
"clipboard-copy": "^1.2.0",
"cookie": "^0.3.1",
"currency-formatter": "^1.4.2",
"dotenv": "^6.1.0",
"fbemitter": "^2.1.1",
"fecha": "^2.3.3",
"formik": "^0.11.11",
"graphql": "^14.0.2",
"graphql-tag": "^2.10.0",
"hh-mm-ss": "^1.2.0",
"isomorphic-fetch": "^2.2.1",
"lodash": "^4.17.4",
"moment": "^2.22.2",
"ms": "^2.1.1",
"next": "^8.0.0-canary.2",
"next-nprogress": "^1.1.0",
"rc-slider": "^8.6.1",
"react": "^16.3.0",
"react-adopt": "^0.6.0",
"react-apollo": "^2.1.1",
"react-click-outside-component": "^1.1.1",
"react-desktop": "^0.3.3",
"react-dom": "^16.3.0",
"react-dropzone": "^4.0.1",
"react-helmet": "^5.2.0",
"react-keydown": "^1.9.6",
"react-maskedinput": "^4.0.0",
"react-modal": "^3.1.4",
"react-powerplug": "^1.0.0-rc.1",
"react-show": "^2.0.4",
"react-sizeme": "^2.5.2",
"react-sortable-hoc": "^0.8.3",
"react-stripe-elements": "^1.4.1",
"react-tether": "^0.6.1",
"react-toggle-display": "^2.2.0",
"react-transition-group": "^2.2.1",
"round-to": "^3.0.0",
"s-ago": "^1.2.2",
"sentence-case": "^2.1.1",
"simpleheat": "^0.4.0",
"styled-components": "^2.2.1",
"styled-jsx": "^3.1.2",
"superagent": "^3.5.2",
"unique-random-array": "^1.0.1",
"yup": "^0.26.6"
},
"devDependencies": {
"@babel/core": "^7.1.0",
"@babel/plugin-proposal-decorators": "^7.1.0",
"@babel/plugin-syntax-jsx": "^7.0.0",
"@babel/plugin-transform-flow-strip-types": "^7.0.0",
"@babel/plugin-transform-modules-commonjs": "^7.1.0",
"@babel/preset-flow": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/register": "^7.0.0",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "^9.0.0",
"babel-jest": "^23.6.0",
"babel-plugin-module-resolver": "^3.1.1",
"babel-plugin-styled-components": "^1.7.1",
"eslint": "^4.18.2",
"eslint-config-prettier": "^2.9.0",
"eslint-config-standard": "^11.0.0",
"eslint-plugin-flowtype": "^2.41.0",
"eslint-plugin-import": "^2.13.0",
"eslint-plugin-jest": "^21.18.0",
"eslint-plugin-node": "^6.0.1",
"eslint-plugin-prettier": "^2.6.0",
"eslint-plugin-promise": "^3.7.0",
"eslint-plugin-react": "^7.5.1",
"eslint-plugin-standard": "^3.0.1",
"flow-typed": "^2.5.1",
"jest": "^23.6.0",
"npm-run-all": "^4.1.3",
"prettier": "^1.13.7",
"prettier-eslint": "^8.8.0",
"react-test-renderer": "^16.4.2",
"react-testing-library": "^4.1.7"
}
}
System information
- OS: macOS
- Version of Next.js: next@8.0.0-canary.2
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Reactions: 1
- Comments: 25 (19 by maintainers)
I guess that’s a good thing 🤔 I still can’t reproduce the issue. Maybe we can close this issue if it doesn’t show up again.
Sidenote: I noticed you have:
Under the
testenv, in v7+ this is no longer needed asnext/babelwill detectprocess.env.NODE_ENV === 'test'and set that configuration accordingly 🙌@revskill10 was wondering if the following would fix your issue (as in undo it, not allow you to upgrade properly):
rm -rf node_modulesyarn install