【问题标题】:Npm thinks I'm on Windows?Npm 认为我在 Windows 上?
【发布时间】:2021-05-03 16:46:40
【问题描述】:

当我在我的项目中尝试构建时,我得到了这个:

[!] Error: Unexpected character '�' (Note that you need plugins to import files that are not JavaScript)
node_modules/bson/ext/win32/x64/bson.node (1:2)

然后显示了很多看起来像 Windows 可执行文件的垃圾,我无法执行,因为我在 Linux 上。问题是我修改了包以便不包含该文件,MongoDb 中包含的 BSON 包也是如此。

编辑这两个包会导致:

[!] Error: Could not resolve '../build/Release/bson' from ../build/Release/bson?commonjs-external
Error: Could not resolve '../build/Release/bson' from ../build/Release/bson?commonjs-external
    at error (/home/sergio/Documentos/PageHistory/node_modules/rollup/dist/shared/rollup.js:5305:30)
    at ModuleLoader.handleResolveId (/home/sergio/Documentos/PageHistory/node_modules/rollup/dist/shared/rollup.js:18531:24)
    at /home/sergio/Documentos/PageHistory/node_modules/rollup/dist/shared/rollup.js:18487:22
    at async Promise.all (index 0)
    at ModuleLoader.fetchStaticDependencies (/home/sergio/Documentos/PageHistory/node_modules/rollup/dist/shared/rollup.js:18485:34)
    at async Promise.all (index 0)
    at ModuleLoader.fetchModule (/home/sergio/Documentos/PageHistory/node_modules/rollup/dist/shared/rollup.js:18461:9)
    at async Promise.all (index 1)
    at ModuleLoader.fetchStaticDependencies (/home/sergio/Documentos/PageHistory/node_modules/rollup/dist/shared/rollup.js:18485:34)
    at async Promise.all (index 0)

有什么想法吗?

【问题讨论】:

  • 首先,提取minimal reproducible example 并将其包含在您的问题中。另外,请阅读您应用的标签的所有描述,至少有一个是错误的。

标签: node.js linux npm


【解决方案1】:

我终于能够通过删除我从前端和后端共享代码并使用npm install (npm pack <folder> | tail -1) --save 安装的本地包来解决此问题(以避免链接,因为它在部署时给我带来了问题)。

【讨论】:

    猜你喜欢
    • 2016-11-19
    • 2019-03-04
    • 1970-01-01
    • 2022-01-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-06
    • 2013-08-06
    相关资源
    最近更新 更多