Finding the cause of “Unknown provider” errors

后端 未结 4 716
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-30 20:57

I\'m getting the following error:

Error: [$injector:unpr] Unknown provider: nProvider <- n

I know this is being caused by the minifi

4条回答
  •  深忆病人
    2021-01-30 21:49

    I understand the question and I have an answer, it's only slightly convoluted.

    The way I found the problem was to rename all identifiers to make them ALL unique, then you get something useful to look for in your compiled javascript which will hopefully point you towards the culprit.

    download my modified version of uglify (pull request pending...)

    brew install node if you don't have node installed.

    ./bin/uglifyjs --unique_ids original.min.js >new.min.js

    Now replace your compiled js with new.min.js and load your app to reproduce the problem now you should get a dependency injection error like n4536

    If your editor is awesome with super long lines you can just load new.min.js, look for n4536 and hopefully that'll help you identify the culprit.

    If not this'll work to print some context around the problem. egrep -o '.{199}n4536.{99}' new.min.js

提交回复
热议问题