Does the pound sign (#) start a comment in JavaScript? I have a website I am using with NPM and when I tried to minify the JavaScript with Grunt, Uglify threw the error:
Warning: Uglification failed.
Unexpected character '#'.
Line 1 in app/min-libs/node_modules/grunt-contrib-jshint/node_modules/jshint/nod
e_modules/cli/examples/cat.js
Use --force to continue.
The file name being referred to seems to be from another NPM module, meaning they know what they are doing. So when I went to app/min-libs/node_modules/grunt-contrib-jshint/node_modules/jshint/node_modules/cli/examples/cat.js, the offending line says:
#!/usr/bin/env node
Is this a comment or do the owners of this NPM module know some super-secret forbidden JavaScript technique?
It is not a JavaScript technique, but a *nix OS one. It is called
shebang
. Quoting from WikiSo, the
cat.js
file can be executed in the shell, like an executable (if it has executable permission).instead of