后端也可以亲⾃使⽤IDEA调试angular代码
有时间为了⼀个问题,需要来来回回跟前端同事联合调试了好多次,既浪费时间,⼜耽误了前端的进度,OK,为了节省⼤家的时间,我们⾃⼰开动吧!
安装nodejs
path=D:\Program Files\nodejs\
在CMD测试安装是否完成:
npm r-version
6.5.0-next.0
下载angular源码
得到源码之后,IDEA直接file - open既可打开angular项⽬,到项⽬根⽬录下的package.json,这相当于java项⽬的l,⾥⾯配置好了编译、运⾏这个项⽬的命令:
笔者试着运⾏build,系统提⽰识别不了“ng”命令。
打开terminal,运⾏npm install -g @angular/cli,进⾏依赖的安装,出现了很多ERR:
$ npm install
npm WARN tarball tarball data for echarts@4.2.0-rc.2 (sha1-apg5eq+oG2XL8LwV2a/b+yRN+R4=) seems to be corrupted. Trying one more time.
npm ERR! path E:\gitlocal\qdam-web\baseline-qdam\node_modules\.staging\echarts-3609cf96\dist\echarts.js
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall unlink
npm ERR! Error: EPERM: operation not permitted, unlink 'E:\gitlocal\qdam-web\baseline-qdam\node_modules\.staging\echarts-3609cf96\dist\echarts.js' npm ERR! { [Error: EPERM: operation not permitted, unlink 'E:\gitlocal\qdam-web\baseline-qdam\node_modules\.staging\echarts-3609cf96\dist\echarts.js'] npm ERR! cause:
npm ERR! { Error: EPERM: operation not permitted, unlink 'E:\gitlocal\qdam-web\baseline-qdam\node_modules\.staging\echarts-3609cf96\dist\echarts.js' npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path:
npm ERR! 'E:\\gitlocal\\qdam-web\\baseline-qdam\\node_modules\\.staging\\echarts-3609cf96\\dist\\echarts.js' },
npm ERR! stack:
npm ERR! "Error: EPERM: operation not permitted, unlink 'E:\\gitlocal\\qdam-web\\baseline-qdam\\node_modules\\.staging\\echarts-3609cf96\\dist\\echar ts.js'",idea debug
npm ERR! errno: -4048,
npm ERR! code: 'EPERM',
npm ERR! syscall: 'unlink',
npm ERR! path:
npm ERR! 'E:\\gitlocal\\qdam-web\\baseline-qdam\\node_modules\\.staging\\echarts-3609cf96\\dist\\echarts.js',
npm ERR! parent: 'baseline-qdam' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
提⽰某些⽬录权限不够,笔者打开资源管理器,查看源码的权限:
显⽰只读,然后当前⽤户也没有写权限,可是其它的⼯程也都是这个权限啊,抱着试⼀试的⼼态,在这界⾯折腾了⼏分钟,最终还是失败,异常信息和上⾯⼀样。
为了节省时间,笔直⽤管理员⾝份打开CMD,在cmd运⾏nmp install -g @angular/cli
> node-sass@4.12.0 install E:\gitlocal\qdam-web\baseline-qdam\node_modules\node-sass
> node scripts/install.js
Downloading binary from github/sass/node-sass/releases/download/v4.12.0/de
Download complete ] - :
Binary saved to E:\gitlocal\qdam-web\baseline-qdam\node_modules\node-sass\vendor\de
Caching binary to C:\Users\chenlong3\AppData\Roaming\npm-cache\node-sass\4.12.0\de
> husky@1.3.1 install E:\gitlocal\qdam-web\baseline-qdam\node_modules\husky
> node husky install
husky > setting up git hooks
husky > done
> node-sass@4.12.0 postinstall E:\gitlocal\qdam-web\baseline-qdam\node_modules\node-sass
> node scripts/build.js
Binary found at E:\gitlocal\qdam-web\baseline-qdam\node_modules\node-sass\vendor\de
Testing binary
Binary is fine
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.
9: wanted {"os":"darwin","arch":"any"} (current: {"os":"wi n32","arch":"x64"})
added 1277 packages from 2147 contributors and audited 42640 packages in 1475.123s
found 19 vulnerabilities (11 low, 8 high)
run `npm audit fix` to fix them, or `npm audit` for details
这个命令系统运⾏了⼤概15分钟的样⼦。(等于绕开了上⾯的terminal权限问题,⽹友如果知道解决办法,请在评论中赐教)
运⾏项⽬
如图进⼊Run Configurations配置:
如果前⾯都配置正确,console应该会输出:
To debug the "start" script, make sure the %NODE_DEBUG_OPTION% string is specified as the first argument for the node command you'd like to debug. For example:
"scripts": {
"start": "node %NODE_DEBUG_OPTION% server.js"
}
> baseline-qdam@1.0.0 start E:\gitlocal\qdam-web\baseline-qdam
> ng serve --disable-host-check
WARNING: Running a server with --disable-host-check is a security risk. See medium/webpack/webpack-dev-server-middleware-security-issue s-1489d950874a for more information.
** Angular Live Development Server is listening on localhost:4200, open your browser on localhost:4200/qdam **
i wds : Project is running at localhost:4200/
i wds : webpack output is served from /qdam
i wds : Content not from webpack is served from E:\gitlocal\qdam-web\baseline-qdam
i wds : 404s will fallback to /qdam/index.html
i wdm : wait until bundle finished: /qdam/index.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论