gpt4 book ai didi

javascript - 尝试运行 meteor 应用程序时 const {LEVEL,MESSAGES} 出现语法错误

转载 作者:行者123 更新时间:2023-11-29 23:24:04 33 4
gpt4 key购买 nike

我正在接手一个使用 Meteor 1.4.2.3 版开发的项目。使用 meteor run 运行项目后,出现以下异常:

W20180411-12:35:00.369(-4)? (STDERR) packages\modules.js:583
W20180411-12:35:00.603(-4)? (STDERR) const {LEVEL, MESSAGE} = require('triple-beam');
W20180411-12:35:00.603(-4)? (STDERR) ^
W20180411-12:35:00.603(-4)? (STDERR)
W20180411-12:35:00.604(-4)? (STDERR) SyntaxError: Unexpected token {
W20180411-12:35:00.604(-4)? (STDERR) at Object.exports.runInThisContext (vm.js:53:16)
W20180411-12:35:00.604(-4)? (STDERR) at C:\Users\roberth\Programming Projects\xxx\.meteor\local\build\programs\server\boot.js:289:30
W20180411-12:35:00.605(-4)? (STDERR) at Array.forEach (native)
W20180411-12:35:00.605(-4)? (STDERR) at Function._.each._.forEach (C:\Users\roberth\AppData\Local\.meteor\packages\meteor-tool\1.4.2_3\mt-os.windows.x86_32\dev_bundle\server-lib\node_modules\underscore\underscore.js:79:11)
W20180411-12:35:00.605(-4)? (STDERR) at C:\Users\roberth\Programming Projects\xxx\.meteor\local\build\programs\server\boot.js:128:5
W20180411-12:35:00.605(-4)? (STDERR) at C:\Users\roberth\Programming Projects\xxx\.meteor\local\build\programs\server\boot.js:344:5
W20180411-12:35:00.606(-4)? (STDERR) at Function.run (C:\Users\roberth\Programming Projects\xxx\.meteor\local\build\programs\server\profile.js:480:12)
W20180411-12:35:00.606(-4)? (STDERR) at C:\Users\roberth\Programming Projects\xxx\.meteor\local\build\programs\server\boot.js:343:11
=> Exited with code: 1

我尝试了以下方法:

  • window :
    • 卸载 nodejs v6 并安装 v8
    • 卸载 meteor 并使用 choco 重新安装
  • Linux:
    • 使用包管理器安装 Node (v6.12.3)
    • 使用 sh 安装 meteor

同样的错误发生在 Windows 和 Linux 上,老实说,我不知道是什么导致了这个问题。

我在这里错过了什么?

编辑

package.json

{
"name": "meteor",
"private": true,
"scripts": {
"start": "meteor run"
},
"dependencies": {
"babel": "^6.23.0",
"babel-cli": "^6.26.0",
"babel-runtime": "6.18.0",
"bson-ext": "^1.0.1",
"meteor-node-stubs": "~0.2.0",
"moment": "^2.17.1",
"mongoose": "~4.4",
"triple-beam": "^1.1.0",
"winston": "2.x",
"winston-mongodb": "latest"
}
}

更新

因为我不知道 meteor 使用内置版本的 Node,所以我卸载了 node、meteor 并删除了 repo。然后我通过 choco 安装了 meteor 并克隆了存储库。在运行 meteor npm install 之后运行 meteor run 我收到了与上述意外 token 完全相同的问题。

更新 2

我已经能够确定 node_modules 目录有问题。如果我将 node_modules 目录从工作机器复制到我的开发箱,它会按预期工作。

新问题:如何确定哪个包有问题?我犹豫是否将 node_modules 目录作为修复提交到 git 中,并且想深入了解它。

最佳答案

看起来您的违规行来自 winston-mongodb 包。自 Meteor 1.4 发布以来,它经历了 2 个主要版本。

因此很可能 package.json 中的 semver 规范 "latest" 太松了。它允许全新安装以获取最新版本的软件包,它使用与您的 Meteor 版本附带的 Node 版本不兼容的新 ES 语法。

正如@Pogrindis 所建议的,您应该能够通过检查工作安装的 node_modules 来确定要使用的正确 winston-mogodb 版本。

您也可以尝试升级 Meteor。 1.6 版现在使用 Node 8+。

还有一种不太可能的可能性是,您的工作安装中的包已在本地转译。如果限制包版本仍然不起作用,那么这就更有可能了。

关于javascript - 尝试运行 meteor 应用程序时 const {LEVEL,MESSAGES} 出现语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49780668/

33 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com