离子服务不适用于离子 4

Ionic serve is not working for Ionic 4

我使用 npm install -g ionic@4.1.0

升级了 ionic

我用 ionic start ionic-4-project blank --type=angular

开始了一个新项目

我试图通过 ionic serve

为项目服务

这是控制台中的错误消息。

> ng run app:serve --host=0.0.0.0 --port=8100
[ng] Could not find API compiler-cli, function VERSION
[ng] Error: Could not find API compiler-cli, function VE
RSION
[ng]     at _error (C:\Users\Me\AppData\Roaming\npm\node
_modules\@angular-devkit\build-angular\node_modules\@ngt
ools\webpack\src\ngtools_api.js:8:11)
[ng]     at getApiMember (C:\Users\Me\AppData\Roaming\np
m\node_modules\@angular-devkit\build-angular\node_module
s\@ngtools\webpack\src\ngtools_api.js:11:32)
[ng]     at Object.<anonymous> (C:\Users\Me\AppData\Roam
ing\npm\node_modules\@angular-devkit\build-angular\node_
modules\@ngtools\webpack\src\ngtools_api.js:50:19)
[ng]     at Module._compile (module.js:652:30)
[ng]     at Object.Module._extensions..js (module.js:663
:10)

[ng]     at Module.load (module.js:565:32)
[ng]     at tryModuleLoad (module.js:505:12)
[ng]     at Function.Module._load (module.js:497:3)
[ng]     at Module.require (module.js:596:17)
[ng]     at require (internal/module.js:11:18)
[ng]     at Object.<anonymous> (C:\Users\Me\AppData\Roam
ing\npm\node_modules\@angular-devkit\build-angular\node_
modules\@ngtools\webpack\src\angular_compiler_plugin.js:
28:23)
[ng]     at Module._compile (module.js:652:30)
[ng]     at Object.Module._extensions..js (module.js:663
:10)
[ng]     at Module.load (module.js:565:32)
[ng]     at tryModuleLoad (module.js:505:12)
[ng]     at Function.Module._load (module.js:497:3)

[ERROR] A utility CLI has unexpectedly closed (exit code
 1).

        The Ionic CLI will exit. Please check any output
 above for error
        details.
net.js:704
    throw new TypeError(

    ^

TypeError: Invalid data, chunk must be a string or buffer, not object
    at WriteStream.Socket.write (net.js:704:11)
    at process.<anonymous> (C:\Users\Me\AppData\Roaming\npm\node_modules\ionic\bin\ionic:9:63)
    at emitTwo (events.js:126:13)
    at process.emit (events.js:214:7)
    at emitPendingUnhandledRejections (internal/process/promises.js:108:22)
    at process._tickCallback (internal/process/next_tick.js:189:7)
PS C:\Users\Me\Desktop\WebApps\fo\ionic-4-pd>

请告诉我您可能需要的其他信息。谢谢。

我在寡妇 10 节点版本:8.11.3 Npm 版本:6.4.0

删除node_modules。然后使用 'npm cache clean --verify' 清除 npm 缓存。然后执行 npm 安装。

npm config set -g production false

然后我开始了一个新项目,一切正常。