Ionic2 查找 ts 文件所在的 js 文件



我正在使用 Ionic 2,但出现以下错误:

Error: Module build failed: Error: ENOENT: no such file or directory, open

'E:\Development\IDE\ionic-apps\theWhoZoo-chat\src\pages\model\mapRangeModel.js' 错误(本机)

如您所见,它正在寻找一个js文件。但这显然在src文件夹下不存在。它具有等效的ts文件。

即此文件确实存在:

srcpagesmodelmapRangeModel.ts

buildmain.js

/***/ function(module, exports) {
throw new Error("Module build failed: Error: ENOENT: no such file or directory, open 'E:\Development\IDE\ionic-apps\theWhoZoo-chat\src\pages\model\mapRangeModel.js'n    at Error (native)");
/***/ },

更多信息:

当我运行ionic serve时,我的 CLI 中也收到以下错误:

[12:26:34]  watch failed: A watch configured to watch the following paths failed to start. It likely that a file
            referenced does not exist: E:DevelopmentIDEionic-appstheWhoZoo-chatsrcassets***,
            E:DevelopmentIDEionic-appstheWhoZoo-chatsrcindex.html,
            E:DevelopmentIDEionic-appstheWhoZoo-chatsrcmanifest.json,
            E:DevelopmentIDEionic-appstheWhoZoo-chatsrcservice-worker.js,
            E:DevelopmentIDEionic-appstheWhoZoo-chatnode_modulesioniconsdistfonts***,
            E:DevelopmentIDEionic-appstheWhoZoo-chatnode_modulesionic-angularfonts***,
            E:DevelopmentIDEionic-appstheWhoZoo-chatnode_modulesionic-angularpolyfillspolyfills.js,
            E:DevelopmentIDEionic-appstheWhoZoo-chatnode_modulessw-toolboxsw-toolbox.js

离子信息:

Your system information:
 ordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.4
Ionic CLI Version: 2.1.18
Ionic App Lib Version: 2.1.9
Ionic App Scripts Version: 1.0.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v6.9.2
Xcode version: Not installed

包.json

{
  "name": "ionic-hello-world",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "2.2.1",
    "@angular/compiler": "2.2.1",
    "@angular/compiler-cli": "2.2.1",
    "@angular/core": "2.2.1",
    "@angular/forms": "2.2.1",
    "@angular/http": "2.2.1",
    "@angular/platform-browser": "2.2.1",
    "@angular/platform-browser-dynamic": "2.2.1",
    "@angular/platform-server": "2.2.1",
    "@ionic/storage": "1.1.7",
    "@types/googlemaps": "^3.25.42",
    "angular2-moment": "^1.1.0",
    "angularfire2": "^2.0.0-beta.7.1-pre",
    "firebase": "^3.6.4",
    "ionic-angular": "2.0.0-rc.4",
    "ionic-native": "2.2.11",
    "ionicons": "3.0.0",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "0.6.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "^1.0.0",
    "typescript": "^2.0.9"
  },
  "cordovaPlugins": [
    "cordova-plugin-whitelist",
    "cordova-plugin-console",
    "cordova-plugin-statusbar",
    "cordova-plugin-device",
    "cordova-plugin-splashscreen",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [],
  "description": "theWhoZoo-chat: An Ionic project"
}

任何帮助表示赞赏。

上述错误是由于导入时区分大小写的问题引起的。

在我的示例中,我正在执行以下操作:

import { MapRangeModel } from '../model/maprangeModel';

当它应该是:

import { MapRangeModel } from '../model/mapRangeModel';

就我而言,问题是我在 windows 命令提示符下使用不区分大小写的目录名称导航到我的项目,如下所示:

"C:/Users/.../my documents/project1/"

这对于 Windows 命令提示符来说没有问题(Windows 对目录不区分大小写),但是当 Ionic 脚本获取当前工作目录时,Windows 返回大小写不正确的目录,最终会抛出此错误。我必须使用正确的名称和大小写来导航目录(始终建议使用选项卡快捷键):

"C:/用户/.../我的文档/项目1/"

相关内容

  • 没有找到相关文章

最新更新