Ionic Framework:在全新安装后,离子服务在示例项目中失败

时间:2016-11-14 11:22:19

标签: cordova ionic-framework ionic2

我正在运行Windows 7 64位,目前正在尝试设置Ionic Framework。我已经在v1中完成了所有工作,但在通过安装Windows SDK修复了一些与VCBuild相关的问题后,ionic serve在通过ionic start MyApp blank --v2创建新项目后失败。

我从脚本中获得正常输出:

[20:53:13]  ionic-app-scripts 0.0.43
[20:53:13]  watch started ...
[20:53:13]  build dev started ...
[20:53:13]  clean started ...
[20:53:13]  clean finished in 16 ms
[20:53:13]  copy started ...
[20:53:13]  transpile started ...
[20:53:18]  transpile finished in 5.17 s
[20:53:18]  webpack started ...
[20:53:18]  copy finished in 5.40 s
[20:53:18]  webpack finished in 281 ms
[20:53:18]  sass started ...
[20:53:20]  sass finished in 1.33 s
[20:53:20]  build dev finished in 6.79 s
[20:53:20]  watch ready in 6.95 s
[20:53:20]  dev server running: http://localhost:8100/

但是在浏览器中传递的页面是空白的,控制台中出现以下Javascript错误:

Uncaught Error: Module build failed: TypeError: Cannot read property 'content' of undefined
    at Object.typescriptSourcemapLoaderMemory (C:\Users\Me\Documents\ionic\MyApp\node_modules\@ionic\app-scripts\dist\webpack\typescript-sourcemap-loader-memory.js:18:34)
    at Object.typescriptSourcemapLoaderMemory (C:\Users\Me\Documents\ionic\MyApp\node_modules\@ionic\app-scripts\dist\webpack\typescript-sourcemap-loader-memory.js:18:34)
    at eval (webpack:///C:/Users/Me/Documents/ionic/MyApp/src/app/main.dev.ts?:1:7)
    at Object.<anonymous> (http://localhost:8100/build/main.js:71:1)
    at __webpack_require__ (http://localhost:8100/build/main.js:20:30)
    at http://localhost:8100/build/main.js:64:18
    at http://localhost:8100/build/main.js:67:10

进一步检查后,应该从typescript源构建的www / build / main.js文件最后会出现此错误的来源:

/******/ ([
/* 0 */
/***/ function(module, exports) {

eval("throw new Error(\"Module build failed: TypeError: Cannot read property 'content' of undefined\\n    at Object.typescriptSourcemapLoaderMemory (C:\\\\Users\\\\Mack\\\\Documents\\\\ionic\\\\chatroom\\\\node_modules\\\\@ionic\\\\app-scripts\\\\dist\\\\webpack\\\\typescript-sourcemap-loader-memory.js:18:34)\");\n\n//////////////////\n// WEBPACK FOOTER\n// C:/Users/Mack/Documents/ionic/chatroom/src/app/main.dev.ts\n// module id = 0\n// module chunks = 0\n\n//# sourceURL=webpack:///C:/Users/Mack/Documents/ionic/chatroom/src/app/main.dev.ts?");

/***/ }
/******/ ]);

所以看起来问题出在打字稿构建过程中 - 但没有一个脚本抱怨。清理和/或手动删除www / build目录无效,文件重建方式相同。

如何解决此问题?我已经搜索过,但在其他任何地方都找不到这个问题。

1 个答案:

答案 0 :(得分:0)

尝试较早版本的ionic-app-scripts。您可以强制按npm install ionic-app-scripts@0.0.38安装特定版本。