我对nuxt相当陌生,目前正在使用它开发我的第一个站点,但遇到一个我无法弄清楚的错误。我的WSL Ubuntu开发环境运行良好,直到我不小心运行了npm run build而不是npm run dev。现在,每次我尝试运行dev时,都会得到以下信息:
HEAD
这是错误日志:
> nuxt
FATAL Unexpected token export 15:54:51
export default {
^^^^^^
SyntaxError: Unexpected token export
at Object.compileFunction (vm.js:406:10)
at Generator.next (<anonymous>)
╭──────────────────────────────────────────╮
│ │
│ ✖ Nuxt Fatal Error │
│ │
│ SyntaxError: Unexpected token export │
│ │
╰──────────────────────────────────────────╯
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! dogabel@1.0.0 dev: `nuxt`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the dogabel@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! /home/hughbom/.npm/_logs/2020-07-21T13_54_51_067Z-debug.log
这是我的nuxt.config.js
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/local/bin/npm', 'run', 'dev' ]
2 info using npm@6.14.6
3 info using node@v10.19.0
4 verbose run-script [ 'predev', 'dev', 'postdev' ]
5 info lifecycle dogabel@1.0.0~predev: dogabel@1.0.0
6 info lifecycle dogabel@1.0.0~dev: dogabel@1.0.0
7 verbose lifecycle dogabel@1.0.0~dev: unsafe-perm in lifecycle true
8 verbose lifecycle dogabel@1.0.0~dev: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/hughbom/dogabel/node_modules/.bin:/home/hughbom/.vscode-server/bin/17299e413d5590b14ab0340ea477cdd86ff13daf/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/mnt/c/Python38/Scripts/:/mnt/c/Python38/:/mnt/d/Programs/bin:/mnt/d/Programs/libnvvp:/mnt/c/Program Files (x86)/Common Files/Oracle/Java/javapath:/mnt/c/Program Files (x86)/Razer Chroma SDK/bin:/mnt/c/Program Files/Razer Chroma SDK/bin:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Users/brad drac/AppData/Local/Microsoft/WindowsApps:/mnt/c/Program Files (x86)/Calibre2/:/mnt/c/Program Files/NVIDIA Corporation/NVIDIA NvDLISR:/mnt/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/mnt/c/Program Files/dotnet/:/mnt/c/Program Files/NVIDIA Corporation/Nsight Compute 2019.4.0/:/mnt/c/Users/brad drac/Documents/opencv/build/x64/vc14/bin:/mnt/c/Program Files/nodejs/:/mnt/c/ProgramData/chocolatey/bin:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program Files/Git/cmd:/mnt/c/Users/brad drac/AppData/Local/Programs/Microsoft VS Code/bin:/mnt/c/Users/brad drac/AppData/Roaming/npm:/snap/bin
9 verbose lifecycle dogabel@1.0.0~dev: CWD: /home/hughbom/dogabel
10 silly lifecycle dogabel@1.0.0~dev: Args: [ '-c', 'nuxt' ]
11 silly lifecycle dogabel@1.0.0~dev: Returned: code: 1 signal: null
12 info lifecycle dogabel@1.0.0~dev: Failed to exec dev script
13 verbose stack Error: dogabel@1.0.0 dev: `nuxt`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:198:13)
13 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:198:13)
13 verbose stack at maybeClose (internal/child_process.js:982:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid dogabel@1.0.0
15 verbose cwd /home/hughbom/dogabel
16 verbose Linux 4.19.104-microsoft-standard
17 verbose argv "/usr/bin/node" "/usr/local/bin/npm" "run" "dev"
18 verbose node v10.19.0
19 verbose npm v6.14.6
20 error code ELIFECYCLE
21 error errno 1
22 error dogabel@1.0.0 dev: `nuxt`
22 error Exit status 1
23 error Failed at the dogabel@1.0.0 dev script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
我不知道错误消息和日志出了什么问题(也许我需要翻译一些东西?),所以将不胜感激。
答案 0 :(得分:0)
导出语句不适用于nuxt.config.js
将export default
更改为'module.exports ='
module.exports = {
// nuxt config
};