Angular2 Build --prod 报错

Angular2 Build --prod 报错

报错如下

Text jicg$ ng build --prod
fs.js:641                                                                               
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open '/Users/jicg/Documents/WebstormProjects/Text/node_modules/._@angular_common@4.3.4@@angular/package.json'
    at Error (native)
    at Object.fs.openSync (fs.js:641:18)
    at Object.fs.readFileSync (fs.js:509:33)
    at licensePlugin.readPackageJson (/Users/jicg/Documents/WebstormProjects/Text/node_modules/._license-webpack-plugin@0.5.1@license-webpack-plugin/index.js:26:19)
    at licensePlugin.getModuleInfo (/Users/jicg/Documents/WebstormProjects/Text/node_modules/._license-webpack-plugin@0.5.1@license-webpack-plugin/index.js:30:28)
    at licensePlugin.<anonymous> (/Users/jicg/Documents/WebstormProjects/Text/node_modules/._license-webpack-plugin@0.5.1@license-webpack-plugin/index.js:81:31)
    at Array.filter (native)
    at licensePlugin.writeModuleInfo (/Users/jicg/Documents/WebstormProjects/Text/node_modules/._license-webpack-plugin@0.5.1@license-webpack-plugin/index.js:77:8)
    at licensePlugin.gatherModuleInfo (/Users/jicg/Documents/WebstormProjects/Text/node_modules/._license-webpack-plugin@0.5.1@license-webpack-plugin/index.js:117:10)
    at licensePlugin.<anonymous> (/Users/jicg/Documents/WebstormProjects/Text/node_modules/._license-webpack-plugin@0.5.1@license-webpack-plugin/index.js:233:12)
    at Compiler.applyPlugins (/Users/jicg/Documents/WebstormProjects/Text/node_modules/._tapable@0.2.8@tapable/lib/Tapable.js:61:14)
    at emitRecords.err (/Users/jicg/Documents/WebstormProjects/Text/node_modules/._webpack@3.4.1@webpack/lib/Compiler.js:268:11)
    at Compiler.emitRecords (/Users/jicg/Documents/WebstormProjects/Text/node_modules/._webpack@3.4.1@webpack/lib/Compiler.js:375:38)
    at emitAssets.err (/Users/jicg/Documents/WebstormProjects/Text/node_modules/._webpack@3.4.1@webpack/lib/Compiler.js:262:10)
    at applyPluginsAsyncSeries1.err (/Users/jicg/Documents/WebstormProjects/Text/node_modules/._webpack@3.4.1@webpack/lib/Compiler.js:368:12)
    at next (/Users/jicg/Documents/WebstormProjects/Text/node_modules/._tapable@0.2.8@tapable/lib/Tapable.js:218:11)
阅读 4.7k
5 个回答

这个情形我也遇到了,应该是--prod这个参数进行了更严格的检测,最新版本的cli使用cnpm的包导致的冲突吧,由于我电脑上面使用不了npm,所以我退回到了之前的cli版本,等官方可以用了在升级.

谢谢楼上的各位,改成 ng build --prod --no-extract-license,就可以打包了

你要跑项目根目录执行。。

你是用cnpm安装依赖包的吗?
如果是的话,换成npm安装

fix this issus step:

  • delete node_modules
  • run npm install -g nrm

    • run nrm use taobao
    • run npm instll
    • -----or------
    • run nrm use cnpm
    • run npm instll

good luck!

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题