My Rails project now includes the browserify
and pinyin
packages, thanks to the browserify-rails
installation.
To find out more about the pinyin
package, check out this link: https://github.com/hotoo/pinyin
var pinyin = require("pinyin");
console.log(pinyin("中心")); // [ [ 'zhōng' ], [ 'xīn' ] ]
Although everything seems to be working fine, I've encountered an issue when trying to use the library from the Google Chrome console.
> pinyin
VM362:1 Uncaught ReferenceError: pinyin is not defined
at <anonymous>:1:1
(anonymous) @ VM362:1
> var pinyin = require("pinyin");
VM364:1 Uncaught ReferenceError: require is not defined
at <anonymous>:1:15
It appears that the pinyin
variable isn't declared as I initially thought, and the require
function can't be accessed from the console environment.
How can I successfully utilize the library in a REPL environment?