-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
npm_prompt.lua:11: attempt to concatenate local 'package_version' (a nil value) #700
Comments
@shiroming, this was fixed in upstream, the fix will be available in Cmder 1.3.0. At this time you cant try to apply vladimir-kotikov/clink-completions@1cea322 manually to your |
got it。 There's no wrong information now. Will show
package.json
|
Yup, everything is correct. Your |
OK,I add "name" and "version" manually. |
@MartiUK , @Stanzilla, this probably could be closed. |
@vladimir-kotikov But what if I use npm just for pulling in dependencies with |
@adiachenko, actually i'm inclined to replace |
Hi. I'm a little lost here. Got the same issue with a Laravel project under PHPStorm. Got this message: C:\cmder/vendor/clink-completions/npm_prompt.lua:11: attempt to concatenate local 'package_version' )e What approach did you use to solve it? |
@jpruiz114, take a look at the 2nd comment on this thread and apply that change to your |
Hey @vladimir-kotikov thanks for your message. I'm a little confused here because there are two files: npm.lua and npm_prompt.lua In your fix from here: vladimir-kotikov/clink-completions@1cea322 ... you were applying a patch to npm.lua including the function inside npm_prompt.lua I tried adding the code to both files but still got the weird message: Thanks in advance for your help! |
check your |
@Stanzilla, why clean @jpruiz114, you need to add changes to |
@vladimir-kotikov because we changed around what is in there and when users upgrade by just copying the new files into the folder, some old stuff stays around and causes problems like the lambda not showing up because clink was called twice etc, that's why I like to make sure people only have the one lua file there that is actually used at the moment. But I guess it was not the case here. |
hey guys, just to let you know that I actually found another solution that worked from a Chinese blog. I was getting this c:\cmder/vendor/clink-completions/npm_prompt.lua:11: attempt to concatenate local 'package_version' (a nil value) The original ...
local package_name = string.match(package_info, '"name"%s*:%s*"(%g-)"')
local package_version = string.match(package_info, '"version"%s*:%s*"(.-)"')
... and the change is (AFTER FIX): ...
local package_name = string.match(package_info, '"name"%s*:%s*"(%g-)"')
if package_name == nil then
package_version = ''
end
local package_version = string.match(package_info, '"version"%s*:%s*"(.-)"')
if package_version == nil then
package_version = ''
end |
@ghiscoding The fix you found has a bug where it does not set The solution that worked for me was to edit the file: ...
local package_name = string.match(package_info, '"name"%s*:%s*"(%g-)"')
if package_name == nil then
package_name = ''
end
local package_version = string.match(package_info, '"version"%s*:%s*"(.-)"')
if package_version == nil then
package_version = ''
end
... |
I would suggest one additional change to get rid of the stray
|
Thanks all for your inspiration. If you feel comfortable to have an automatic check for the right version and name field of your package.json leave it as it is. Otherwise for me it feels right when there is no package_name and package_version it shouldn't display anything. This is my modification of
Tested with cmder version v1.2.9 Update in v1.3.0-pre you have to comment out the last line |
npm_prompt.lua (v1.2.9) local color = require('color')
function npm_prompt_filter()
local package = io.open('package.json')
if package ~= nil then
local package_info = package:read('*a')
package:close()
local package_private = string.match(package_info, '"private"%s*:%s*true')
if package_private == nil then
local package_name = string.match(package_info, '"name"%s*:%s*"(%g-)"')
local package_version = string.match(package_info, '"version"%s*:%s*"(.-)"')
local package_string = color.color_text("("..package_name.."@"..package_version..")", color.YELLOW)
clink.prompt.value = clink.prompt.value:gsub('{git}', '{git} '..package_string)
end
end
return false
end
clink.prompt.register_filter(npm_prompt_filter, 40) |
If private, u don't need the name or version !! |
Can confirm this issue is happening to me right now. Just upgraded to the latest version. |
Yep me too! @visualcookie did you fixed it? |
@iamfreee Yeah, just copy and pasted @danilobrinu solution and now it works again. |
Hi, I am getting the same error now and the previous fixes seem to not work on this. Do you have any suggestions? |
@csmithersslc i can help you, i fixed the previous version :) |
@danilobrinu Thank you! |
@csmithersslc tell me about your issues. Post prints and tag me. |
Sure @danilobrinu I cd'ed into a new directory and this was the output: The npm_prompt file reads as @pantox's on Apr 1st. And the npm one is as follows:
end` |
@csmithersslc what is your cmder version ?? u can use this code function npm_prompt_filter()
local package = io.open('package.json')
if package ~= nil then
local package_info = package:read('*a')
package:close()
local package_private = string.match(package_info, '"private"%s*:%s*true')
if package_private == nil then
local package_name = string.match(package_info, '"name"%s*:%s*"(%g-)"')
local package_version = string.match(package_info, '"version"%s*:%s*"(.-)"')
local package_string = color.color_text("("..package_name.."@"..package_version..")", color.YELLOW)
clink.prompt.value = clink.prompt.value:gsub('{git}', '{git} '..package_string)
end
end
return false
end |
Wow, that worked perfectly. I show it is version 161022 stable, the newest version. Thank you so much! |
@csmithersslc you can try this code ? function npm_prompt_filter()
local package_file = io.open('package.json')
if package_file then
local package_data = package_file:read('*a')
local package = JSON:decode(package_data)
if package then
if not package.private then
local package_name = package.name or "<no name>"
local package_version = package.version and "@"..package.version or ""
local package_string = color.color_text("("..package_name..package_version..")", color.YELLOW)
clink.prompt.value = clink.prompt.value:gsub('{git}', '{git} '..package_string)
end
end
end
package_file:close()
return false
end |
I have tried it and it worked! Thank you for your help. On Sun, Nov 6, 2016 at 10:58 AM, Danilo Britto Nuñez <
|
@csmithersslc the new version of cmder have fixed, update your cmder o download the latest version :) |
All done. Everything looks good :) On Sun, Nov 6, 2016 at 2:05 PM, Danilo Britto Nuñez <
|
@6bytes download the lastest version of cmder, that issue is fixed. The version of cmder is 1.3.1 not 161206, 1061206 is the version of ConEmu i recommend not update the ConEmu why is probably not compatible with the lastest version of cmder. |
Thank you @danilobrinu I just downloaded latest version and it's all working fine :) |
I use webstorm create a react starter kit project.
The text was updated successfully, but these errors were encountered: