【发布时间】:2018-04-05 17:47:00
【问题描述】:
我有一个.npmrc 文件,其中包含:
runtime = electron
target = 1.7.9
target_arch = x64
disturl = https://atom.io/download/atom-shell
build_from_source = true
还有一个package.json 文件:
"scripts": {
"start": "electron .",
"test": "mocha"
}
按照npm install,当我使用npm start 运行我的node.js 脚本时,一切正常。但是,当我使用 npm test 时,我遇到了一个错误:
Uncaught LevelUPError: Failed to require LevelDOWN (The module '/Users/_me_/_project_/node_modules/leveldown/build/Release/leveldown.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 54. This version of Node.js requires
NODE_MODULE_VERSION 57. Please try re-compiling or re-installing
the module (for instance, using 'npm rebuild' or 'npm install').). Try 'npm install leveldown' if it's missing
我的test.js 文件使用了一小部分不需要电子的模块。
我尝试在清除npm_modules 目录后运行npm rebuild、npm install 和npm install leveldown,但错误仍然存在。
知道为什么我会看到这些错误或如何更正此问题吗?
编辑:我能够用电子摩卡切换摩卡并绕过错误。
【问题讨论】:
-
您是否尝试删除
node_modules文件夹并重新安装所有内容? -
@kontrollanten 我有 - 错误仍然存在。然而,
npm start没有抱怨。
标签: node.js npm mocha.js electron leveldb