Webpack编译,找不到本地模块:错误:无法解决

时间:2019-03-28 11:06:05

标签: nativescript

我修改了一个插件,并将其添加到项目的文件系统中。所以在我的package.json中,我有:"some-module": "file:modules/some-module"

它在我的机器(Windows)上运行正常,但在我们的构建服务器(Linux CentOS)上却无法正常运行,该构建服务器在webpack编译期间失败,错误为Module not found: Error: Can't resolve 'some-module'

构建服务器会在构建之前清理工作空间,而构建失败后,插件确实存在于工作空间的“ node_modules”文件夹中。

如果插件确实存在,可能导致此错误的原因是什么?

编辑:我在另一台Linux计算机(CentOS)上尝试运行,并因相同的错误而构建失败。

EDIT2:我将package.json文件中的本地file:更改为.tar.gz git URL。现在的错误是:

ERROR in ../node_modules/nativescript-pdfview-ng/pdfview-ng.ts Module build failed (from ../node_modules/@ngtools/webpack/src/index.js): Error: /root/myProject/node_modules/nativescript-pdfview-ng/pdfview-ng.ts is missing from the TypeScript compilation. Please make sure it is in your tsconfig via the 'files' or 'include' property. The missing file seems to be part of a third party library. TS files in published libraries are often a sign of a badly packaged library. Please open an issue in the library repository to alert its author and ask them to package the library using the Angular Package Format ([link][1]). at AngularCompilerPlugin.getCompiledFile (/root/myProject/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:719:23) at plugin.done.then (/root/myProject/node_modules/@ngtools/webpack/src/loader.js:41:31) at process._tickCallback (internal/process/next_tick.js:68:7)

1 个答案:

答案 0 :(得分:0)

您是否正在使用NativeScript 5.x?

如果是这样,请确保为插件添加“ nativescript-”作为前缀,因为{N} 5.x的模块分辨率似乎已因Webpack的构建而改变。