Closed vexsolutions closed 6 years ago
I downloaded the repo recently from npm and the bug is still active. I realize the line 16 added in vue-truncate.js should prevent this:
Vue.filter('truncate', function (text, length, clamp) {
text = text || ''; // <= this line should prevent the error
Yet, looking at my local copy of vue-truncate.js (the one in my node_modules folder), I see that the line in question is not added. I think npm might have an old version of the repo, maybe?
Edit: It's also possible I just have a wrong configuration in my package.json, but I'm not sure how to check so I figured I might find more info here
What is your version of this package on your package.json
?
I'm not currently on the same PC as before, but I did a quick test:
npm install vue-truncate-filter
on an empty foldernode_modules/vue-truncate-filter/vue-truncate.js
That's why I've been digging into the package.json docs and found this:
The name and version together form an identifier that is assumed to be completely unique. Changes to the package should come along with changes to the version.
It seems like npm is not resolving to the latest version, even though package.json says it does.
For the record, this is exactly the content of package.json after my experiment:
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"vue-truncate-filter": {
"version": "1.1.7",
"resolved": "https://registry.npmjs.org/vue-truncate-filter/-/vue-truncate-filter-1.1.7.tgz",
"integrity": "sha512-kFmUDsDFIj5vArdK6hX84v80fTWJIMrsYF5keCluy9hMiaKGL8NyApnMbWavZeDod24YeYMVQ9jjd7MkRn3AAg=="
}
}
}
I think the problem might be that npm has stored "in cache" an old version. After the commit to fix this bug, the version
in this repository's package.json should have been increased, ending up in 1.1.8
or something like that.
Changing this should make npm keep and distribute the latest version on the code 🙂
Thanks for publishing this repo and hope this helps ~
Would be great if it checked for null and just returned instead of throwing an error.
[Vue warn]: Error in render: "TypeError: Cannot read property 'length' of null"