我第一次使用Ionic。
我正在尝试使用ionic serve
:
watch started ...
build dev started ...
Proxy added:/api => http://[...]
clean started ...
clean finished in 9 ms
copy started ...
transpile started ...
transpile finished in 2.31 s
preprocess started ...
deeplinks started ...
deeplinks finished in 82 ms
preprocess finished in 84 ms
webpack started ...
copy finished in 2.50 s
但服务器无法启动。我不知道问题可能来自哪里。
答案 0 :(得分:1)
假设您使用Ionic 3.6.0。
通常,您会遇到这种类型的错误,因为您将两个或多个类放入一个.ts文件中。
根据您提供的日志,似乎在代码编译和打包期间出现错误。
当您运行离子服务时,Ionic会隐藏错误详细信息。您可以通过运行此命令 npm run build --verbose 来获取详细错误信息。
如果您发现错误类似无法读取属性'substr',则可以尝试将每个类移动到单个.ts文件中。
答案 1 :(得分:0)
npm run build --verbose:
npm info it worked if it ends with ok
npm verb cli [ '/usr/bin/nodejs',
npm verb cli '/usr/local/bin/npm',
npm verb cli 'run',
npm verb cli 'build',
npm verb cli '--verbose' ]
npm info using npm@5.3.0
npm info using node@v6.11.1
npm verb run-script [ 'prebuild', 'build', 'postbuild' ]
npm info lifecycle gecina-plan-prevention@0.0.1~prebuild: gecina-plan-prevention@0.0.1
npm info lifecycle gecina-plan-prevention@0.0.1~build: gecina-plan-prevention@0.0.1
> gecina-plan-prevention@0.0.1 build /srv/pvx/mobile/gecina
> ionic-app-scripts build
[08:40:35] ionic-app-scripts 1.3.4
[08:40:35] build dev started ...
[08:40:35] clean started ...
[08:40:35] clean finished in 1 ms
[08:40:35] copy started ...
[08:40:35] transpile started ...
[08:40:37] transpile finished in 2.37 s
[08:40:37] preprocess started ...
[08:40:37] deeplinks started ...
[08:40:37] deeplinks finished in 88 ms
[08:40:37] preprocess finished in 88 ms
[08:40:37] webpack started ...
[08:40:37] copy finished in 2.57 s
/srv/pvx/mobile/gecina/node_modules/source-map/lib/source-node.js:115
node.add(nextLine.substr(0, mapping.generatedColumn));
^
TypeError: Cannot read property 'substr' of undefined
at Function.<anonymous> (/srv/pvx/mobile/gecina/node_modules/source-map/lib/source-node.js:115:26)
at Array.forEach (native)
at SourceMapConsumer_eachMapping [as eachMapping] (/srv/pvx/mobile/gecina/node_modules/source-map/lib/source-map-consumer.js:155:14)
at Function.SourceNode_fromStringWithSourceMap [as fromStringWithSourceMap] (/srv/pvx/mobile/gecina/node_modules/source-map/lib/source-node.js:80:24)
at SourceMapSource.node (/srv/pvx/mobile/gecina/node_modules/webpack-sources/lib/SourceMapSource.js:42:20)
at ReplaceSource.node (/srv/pvx/mobile/gecina/node_modules/webpack-sources/lib/ReplaceSource.js:69:29)
at CachedSource.node (/srv/pvx/mobile/gecina/node_modules/webpack-sources/lib/CachedSource.js:12:23)
at /srv/pvx/mobile/gecina/node_modules/webpack-sources/lib/ConcatSource.js:40:49
at Array.map (native)
at ConcatSource.node (/srv/pvx/mobile/gecina/node_modules/webpack-sources/lib/ConcatSource.js:39:60)
npm verb lifecycle gecina-plan-prevention@0.0.1~build: unsafe-perm in lifecycle true
npm verb lifecycle gecina-plan-prevention@0.0.1~build: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/srv/pvx/mobile/gecina/node_modules/.bin:/usr/local/pgsql/bin/:/usr/local/pgsql/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
npm verb lifecycle gecina-plan-prevention@0.0.1~build: CWD: /srv/pvx/mobile/gecina
npm info lifecycle gecina-plan-prevention@0.0.1~build: Failed to exec build script
npm verb stack Error: gecina-plan-prevention@0.0.1 build: `ionic-app-scripts build`
npm verb stack Exit status 1
npm verb stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:289:16)
npm verb stack at emitTwo (events.js:106:13)
npm verb stack at EventEmitter.emit (events.js:191:7)
npm verb stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
npm verb stack at emitTwo (events.js:106:13)
npm verb stack at ChildProcess.emit (events.js:191:7)
npm verb stack at maybeClose (internal/child_process.js:891:16)
npm verb stack at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
npm verb pkgid gecina-plan-prevention@0.0.1
npm verb cwd /srv/pvx/mobile/gecina
npm verb Linux 4.4.0-83-generic
npm verb argv "/usr/bin/nodejs" "/usr/local/bin/npm" "run" "build" "--verbose"
npm verb node v6.11.1
npm verb npm v5.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gecina-plan-prevention@0.0.1 build: `ionic-app-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gecina-plan-prevention@0.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm verb exit [ 1, true ]
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ldt/.npm/_logs/2017-08-01T06_40_44_582Z-debug.log
离子信息:
cli packages:
@ionic/cli-plugin-cordova : 1.5.0 (/srv/pvx/mobile/gecina/node_modules/@ionic/cli-plugin-cordova)
@ionic/cli-plugin-ionic-angular : 1.4.0 (/srv/pvx/mobile/gecina/node_modules/@ionic/cli-plugin-ionic-angular)
@ionic/cli-utils : 1.6.0 (/srv/pvx/mobile/gecina/node_modules/@ionic/cli-utils)
ionic (Ionic CLI) : 3.6.0 (/srv/pvx/mobile/gecina/node_modules/ionic)
global packages:
Cordova CLI : 7.0.1
local packages:
@ionic/app-scripts : 1.3.4
Cordova Platforms : android 6.2.3
Ionic Framework : ionic-angular 3.1.1
System:
Node : v6.11.1
OS : Linux 4.4
npm : 5.3.0
ionic serve -l -s -c:
[INFO] Starting app-scripts server: --consolelogs --c --serverlogs --s --lab --l --port 8100 --p 8100 --livereload-port
35729 --r 35729 --address 0.0.0.0 - Ctrl+C to cancel
[08:46:04] watch started ...
[08:46:04] build dev started ...
[08:46:04] Proxy added:/api => http://[...]
[08:46:04] clean started ...
[08:46:04] clean finished in 1 ms
[08:46:04] copy started ...
[08:46:04] transpile started ...
[08:46:06] transpile finished in 2.24 s
[08:46:06] preprocess started ...
[08:46:06] deeplinks started ...
[08:46:06] deeplinks finished in 81 ms
[08:46:06] preprocess finished in 81 ms
[08:46:06] webpack started ...
[08:46:06] copy finished in 2.43 s