Module not found: Error: Can't resolve ...
问题现象
执行Npm构建任务时,日志报如下异常信息:
原因分析
找不到需要的文件。
上图中6068行的错误日志,“Module not found: Error: Can't resolve './App.Vue' in '/xxx/slave1/workspace/job_d5d70df6-9b64-4faa-ba67-93c06d4a1972_1545727944134/src'”,在“src”文件夹下找不到“./App.Vue”文件。可能原因如下:
- 对应文件夹下,没有所需文件。
- 文件路径大小写配置有误。图中代码配置的是“'./App.Vue'”,实际文件名是“'./App.vue'”,导致找不到所需文件。因为Windows系统不区分大小写,而Linux系统区分,所以可能本地能构建成功,在编译构建服务上却构建失败。
处理方法
- 在代码项目中的相应文件夹下,补充错误日志中提示缺失的文件。
- 修改出错的代码中配置的文件路径。
Npm构建 所有常见问题
- JavaScript heap out of memory
- Unexpected end of JSON ...
- enoent ENOENT: no such file or directory
- Module not found: Error: Can't resolve ...
- NPM构建失败,但不显示错误日志
- npm cb() never called
- gyp ERR! stack Error: EACCES: permission denied
- eslint: error 'CLODOP' is not defined
- node-sass下载失败
- error: could not write config file
- npm构建耗时且安装依赖缓慢
- 找不到依赖版本
more