前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >node、npm 、package.json、Angular Cli、webpack之间的关系(Windows环境下)

node、npm 、package.json、Angular Cli、webpack之间的关系(Windows环境下)

作者头像
城市中的游牧民族
发布2022-08-28 14:02:07
3810
发布2022-08-28 14:02:07
举报
文章被收录于专栏:前端真相前端真相

IDE:webstorm,已安装angular插件。

Angular Cli 依赖webpack,简化创建项目流程; npm属于node一部分,npm 从package.json找对应的scripts执行命令,scripts对应的命令也会使用Angular Cli命令,比如ng,从IDE点击ng命令,跳转到项目路径/node_modules/.bin/ng:

代码语言:javascript
复制
#!/bin/sh
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")

case `uname` in
    *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
esac

if [ -x "$basedir/node" ]; then
  "$basedir/node"  "$basedir/../@angular/cli/bin/ng" "$@"
  ret=$?
else 
  node  "$basedir/../@angular/cli/bin/ng" "$@"
  ret=$?
fi
exit $ret

可以看的出它是使用node执行node_modules/@angular/cli/bin/ng:

代码语言:javascript
复制
#!/usr/bin/env node
'use strict';

// Provide a title to the process in `ps`.
// Due to an obscure Mac bug, do not start this title with any symbol.
try {
  process.title = 'ng ' + Array.from(process.argv).slice(2).join(' ');
} catch (_) {
  // If an error happened above, use the most basic title.
  process.title = 'ng';
}

// This node version check ensures that extremely old versions of node are not used.
// These may not support ES2015 features such as const/let/async/await/etc.
// These would then crash with a hard to diagnose error message.
// tslint:disable-next-line: no-var-keyword
var version = process.versions.node.split('.').map(part => Number(part));
if (version[0] < 10 || version[0] === 11 || (version[0] === 10 && version[1] < 13)) {
  console.error(
    'Node.js version ' + process.version + ' detected.\n' +
    'The Angular CLI requires a minimum Node.js version of either v10.13 or v12.0.\n\n' +
    'Please update your Node.js version or visit https://nodejs.org/ for additional instructions.\n'
  );

  process.exitCode = 3;
} else {
  require('../lib/init');
}
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2022-08-27,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档