I use webstorm create a react starter kit project.
E:\code
-> cd react\
C:\cmder/vendor/clink-completions/npm_prompt.lua:11: attempt to concatenate local 'package_version' (a nil value)
E:\code\react {git}{hg}
{lamb}

@shiroming, this was fixed in upstream, the fix will be available in Cmder 1.3.0.
At this time you cant try to apply https://github.com/vladimir-kotikov/clink-completions/commit/1cea322bd6f579e8b8798381fcdd928a3869ce74 manually to your npm_prompt.lua
got it。
THX
There's no wrong information now. Will show
E:\
-> cd code\react\
E:\code\react (<invalid_name>@<invalid_version>)
->
package.json
{
"private": true,
"engines": {
"node": ">=4.1 <5",
"npm": ">=3.1 <4"
},
"dependencies": {
"babel-core": "5.8.29",
"bluebird": "3.0.5",
"classnames": "2.2.0",
"eventemitter3": "1.1.1",
"express": "4.13.3",
"fastclick": "1.0.6",
"fbjs": "0.4.0",
"flux": "2.1.1",
"front-matter": "2.0.0",
"history": "1.13.0",
"jade": "1.11.0",
"normalize.css": "3.0.3",
"react": "0.14.2",
"react-dom": "0.14.2",
"react-routing": "0.0.5",
"source-map-support": "0.3.3",
"superagent": "1.4.0"
},
"devDependencies": {
"autoprefixer": "^6.1.0",
"babel": "^5.8.29",
"babel-eslint": "^4.1.4",
"babel-loader": "^5.3.2",
"babel-plugin-react-transform": "^1.1.1",
"browser-sync": "^2.9.12",
"css-loader": "^0.22.0",
"csscomb": "^3.1.8",
"del": "^2.0.2",
"eslint": "^1.8.0",
"eslint-config-airbnb": "0.1.0",
"eslint-loader": "^1.1.1",
"eslint-plugin-react": "^3.7.1",
"file-loader": "^0.8.4",
"gaze": "^0.5.2",
"git-repository": "^0.1.1",
"glob": "^5.0.15",
"jest-cli": "^0.7.1",
"jscs": "^2.5.0",
"lodash.merge": "^3.3.2",
"mkdirp": "^0.5.1",
"ncp": "^2.0.0",
"postcss": "^5.0.10",
"postcss-cssnext": "^2.2.0",
"postcss-import": "^7.1.3",
"postcss-loader": "^0.7.0",
"postcss-nested": "^1.0.0",
"psi": "^1.0.6",
"react-transform-catch-errors": "^1.0.0",
"react-transform-hmr": "^1.0.1",
"redbox-react": "^1.1.1",
"replace": "^0.3.0",
"style-loader": "^0.13.0",
"url-loader": "^0.5.6",
"webpack": "^1.12.3",
"webpack-dev-middleware": "^1.2.0",
"webpack-hot-middleware": "^2.4.1"
},
"jest": {
"rootDir": "./src",
"scriptPreprocessor": "../preprocessor.js",
"unmockedModulePathPatterns": [
"fbjs",
"react"
]
},
"scripts": {
"lint": "eslint src tools && jscs src tools",
"csslint": "csscomb src/components --lint --verbose",
"csscomb": "csscomb src/components --verbose",
"test": "eslint src && jest",
"clean": "babel-node tools/run clean",
"copy": "babel-node tools/run copy",
"bundle": "babel-node tools/run bundle",
"build": "babel-node tools/run build",
"deploy": "babel-node tools/run deploy",
"serve": "babel-node tools/run serve",
"start": "babel-node tools/run start"
}
}
Yup, everything is correct. Your package.json is missing name and version attributes. (probably because it is a templete and you need to add them manually). See package.json reference here
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 private property in package.json set to true? This new prompt is kind of obtrusive. You may consider replacing <invalid_name> and <invalid_version> with empty string in npm_prompt.lua.
@adiachenko, actually i'm inclined to replace invalid_ -> no_. This would be more appropriate (and less obtrusive :smile: ), than invalid_ or just empty strings (which would give you e.g. @0.0.1 - looks kinda weird). Or, probably remove npm package badge at all if there is neither package name nor version specified.
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 C:\cmder/vendor/clink-completions/npm_prompt.lua
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:
... 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 cmder\vendor dir, the only lua file in there should be clink.lua if you have any extra, delete those and try again.
@Stanzilla, why clean cmder/vendor? I think first we need to ask @jpruiz114, which version he uses?
@jpruiz114, you need to add changes to npm_prompt.lua only. In my patch i added them to npm.lua instead because at some point i decided to merge these two files into one. However latest public Cmder version (1.2.9) doesn't include this merge yet.
@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 npm_prompt.lua was (BEFORE FIX)
...
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 package_name
The solution that worked for me was to edit the file:
{YOUR_PATH}/cmder/vendor/clink-completions/npm_prompt.lua
and overwrite the related lines to be this instead:
...
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 @ character when there is no version present — adding an additional variable package_version_separator and making it blank '' when there is no version
local package_version_separator = '@'
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 = ''
package_version_separator = ''
end
local package_string = color.color_text("("..package_name..package_version_separator..package_version..")", color.YELLOW)
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 cmder\vendor\clink-completions\npm.lua to get rid of all the empty brackets, symbols and stuff.
function npm_prompt_filter()
local package = io.open('package.json')
if package ~= nil then
local package_info = package:read('*a')
package:close()
local package_name = string.match(package_info, '"name"%s*:%s*"(.-)"')
or ""
local package_version = string.match(package_info, '"version"%s*:%s*"(.-)"')
or ""
if package_name == "" and package_version == "" then
local package_string = ""
else
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
Tested with cmder version v1.2.9
Update in v1.3.0-pre
you have to comment out the last line clink.prompt.register_filter(npm_promt_filter, 40) in ´npm.lua´, as a default behaviour will clink display the name and or the version when its provided in the package.json file.
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:
`function npm_prompt_filter()
local package = io.open('package.json')
if package ~= nil then
local package_info = package:read('_a')
package:close()
local package_name = string.match(package_info, '"name"%s_:%s*"(.-)"')
or ""
local package_version = string.match(package_info, '"version"%s*:%s*"(.-)"')
or ""
if package_name == "" and package_version == "" then
local package_string = ""
else
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`
@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 <
[email protected]> wrote:
@csmithersslc https://github.com/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 falseend—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/cmderdev/cmder/issues/700#issuecomment-258697907, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AFUmv8qQFMP4Nr9rfx9lgYk69lhaDo-Kks5q7hU0gaJpZM4GeUZU
.
@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 <
[email protected]> wrote:
@csmithersslc https://github.com/csmithersslc the new version of cmder
have fixed, update your cmder o download the latest version :)—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/cmderdev/cmder/issues/700#issuecomment-258710599, or mute
the thread
https://github.com/notifications/unsubscribe-auth/AFUmv6_vqfsoVdOfwgAMhT5GGTBL7ryUks5q7kEQgaJpZM4GeUZU
.
Hi @danilobrinu
I've been having the same issue for months now. I tried to paste the code you gave @csmithersslc but it didn't work for me :(
I get the following error:

My npm_prompt.lua file looks like this:
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_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
return false
end
clink.prompt.register_filter(npm_prompt_filter, 40)
Just today updated cmder to version 161206 stable.
How can I fix that?
@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 :)
Most helpful comment
Yup, everything is correct. Your
package.jsonis missingnameandversionattributes. (probably because it is a templete and you need to add them manually). See package.json reference here