Ionic:错误:模块构建失败:错误:ENOENT:没有这样的文件或目录 [英] Ionic: Error: Module build failed: Error: ENOENT: no such file or directory

查看:1212
本文介绍了Ionic:错误:模块构建失败:错误:ENOENT:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Ionic,并收到以下错误:

I am using Ionic, and get the following error:


运行时错误未捕获(在承诺中):错误:模块构建失败:
错误:ENOENT:没有这样的文件或目录,打开
'/Users/richardmarais/Development/ionic/theWhoZoo/src/pages/model/ratingModel.js'

Runtime Error Uncaught (in promise): Error: Module build failed: Error: ENOENT: no such file or directory, open '/Users/richardmarais/Development/ionic/theWhoZoo/src/pages/model/ratingModel.js'

错误是这行代码的结果:

The error is a result of this line of code:

this.ratingModel = new RatingModel();

当我删除此行时,我没有收到错误。

When I remove this line, I don't get the error.

ratingModel.ts

import { Injectable } from "@angular/core";
import { PersonModel } from './personModel';
import { JobModel } from './jobModel';

@Injectable()
export class RatingModel {
        public id: number = null;
        public job: JobModel = null;
        public review: string = null;
        public rating: number = null;
        public reviewDate: number = null;
        public time: string = null;
        public person: PersonModel = null;
        public anonymous: number = null;

        constructor() {

        }
}

在阅读其他论坛时,由于案例在导入中没有匹配,人们会收到此错误,但我检查了我的,并且确实匹配。

Reading other forums, people are getting this error due to the case not matching in their imports, but I have checked mine, and they do match.

import { RatingModel } from '../model/ratingModel';

但是,我注意到我的IDE(Visual Studio Code)中有一些奇怪的东西:

However, I have noticed something strange in my IDE (Visual Studio Code):

如您所见,在搜索结果中,有两个该对象的文件, ratingModel.ts RatingModel.ts 。但是当我检查实际文件系统时,只有文件, ratingModel.ts

As you can see, in the search results, there are two files for the object, ratingModel.ts and RatingModel.ts. But when I check the actual files system, there is only on file, ratingModel.ts:

问题

有谁知道什么以及如何解决这里可能出现的错误或错误?

Does anyone know what and how to resolve what looks like possibly a bug or fault here?

谢谢

更多信息:

global packages:

    @ionic/cli-utils : 1.0.0
    Cordova CLI      : 6.4.0 
    Ionic CLI        : 3.0.0

local packages:

    @ionic/app-scripts              : 1.3.0
    @ionic/cli-plugin-cordova       : 1.0.0
    @ionic/cli-plugin-ionic-angular : 1.0.0
    Ionic Framework                 : ionic-angular 3.2.1

System:

    Node       : v7.10.0
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.2 Build version 8E2002 
    ios-deploy : not installed
    ios-sim    : not installed


推荐答案

当您的app.module设置无法找到您的组件时发生此错误。

This error occurred when your component can't be found with your app.module settings.

关注这些步骤可以解决您的问题:

Follow these steps to solve your problem:


  1. 右键单击您的Web浏览器并选择inspect(在这种情况下,我使用chrome)

  2. 在源选项卡中,导航到localhost:8100(运行离子的默认端口)

  3. 转到src - >页面并打开相应页面(在这种情况下) 'model')

  4. .ts文件和路径的名称必须与app.module.ts中添加的导入路径的名称和路径相同

    在这种情况下,没有model / ratingModel.ts


    要注意
    路径区分大小写(也许.ts文件是RatingModel)

  1. Right click on your web browser and select inspect (in this case I use chrome)
  2. In the source tab, navigate to localhost:8100 (the default port for running ionic)
  3. Go to src -> pages and open corresponded page(in this case 'model')
  4. The name of .ts file and path must be as same as the name and path of the added import path in app.module.ts

    In this case, there isn't model/ratingModel.ts

    be aware : The path is case sensitive (maybe the .ts file is RatingModel)

这篇关于Ionic:错误:模块构建失败:错误:ENOENT:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆