我已使用npm-g_nosudo脚本在我的Yosemite安装上安装了var fs = require('fs');
var filename = './80.json';
var bufferString;
function ReadFile(callback) {
fs.readFile(filename, 'utf-8', function(err, data) {
bufferString = data;
callback();
});
}
function PrintLine() {
console.log(JSON.parse(bufferString));
}
ReadFile(PrintLine)
并设置了node.js
。然后,当我运行npm
时,我看到一堆内容滚动到我的终端窗口,没有错误,它就完成了。然后我输入npm install -g yo
,OS X告诉我它无法找到命令。
yo
我也尝试使用Sullys-MacBook-Pro:~ Sully$ npm install -g yo
/Users/Sully/npm/bin/yo -> /Users/Sully/npm/lib/node_modules/yo/lib/cli.js
> yo@1.4.6 postinstall /Users/Sully/npm/lib/node_modules/yo
> yodoctor
Yeoman Doctor
Running sanity checks on your system
✔ Global configuration file is valid
✔ NODE_PATH matches the npm root
✔ No .bowerrc file in home directory
✔ No .yo-rc.json file in home directory
Everything looks all right!
yo@1.4.6 /Users/Sully/npm/lib/node_modules/yo
├── titleize@1.0.0
├── array-uniq@1.0.2
├── figures@1.3.5
├── user-home@1.1.1
├── opn@1.0.2
├── humanize-string@1.0.1 (decamelize@1.0.0)
├── sort-on@1.2.0 (dot-prop@2.0.0)
├── async@0.9.0
├── yeoman-character@1.0.1 (supports-color@1.3.1)
├── string-length@1.0.0 (strip-ansi@2.0.1)
├── cross-spawn@0.2.9 (lru-cache@2.6.2)
├── findup@0.1.5 (commander@2.1.0, colors@0.6.2)
├── chalk@1.0.0 (escape-string-regexp@1.0.3, ansi-styles@2.0.1, supports-color@1.3.1, strip-ansi@2.0.1, has-ansi@1.0.3)
├── yosay@1.0.3 (ansi-regex@1.1.1, ansi-styles@2.0.1, strip-ansi@2.0.1, word-wrap@1.0.3, pad-component@0.0.1, taketalk@1.0.0, minimist@1.1.1)
├── root-check@1.0.0 (downgrade-root@1.1.0, sudo-block@1.2.0)
├── meow@3.1.0 (object-assign@2.0.0, camelcase-keys@1.0.0, minimist@1.1.1, indent-string@1.2.1)
├── package-json@1.1.0 (registry-url@3.0.3)
├── npm-keyword@1.1.1 (registry-url@3.0.3)
├── update-notifier@0.3.2 (is-npm@1.0.0, latest-version@1.0.0, semver-diff@2.0.0)
├── got@2.9.2 (lowercase-keys@1.0.0, timed-out@2.0.0, object-assign@2.0.0, is-stream@1.0.1, prepend-http@1.0.1, nested-error-stacks@1.0.0, statuses@1.2.1, infinity-agent@2.0.3, duplexify@3.3.0, read-all-stream@2.1.2)
├── fullname@1.1.0 (npmconf@2.1.1)
├── yeoman-environment@1.2.5 (log-symbols@1.0.2, escape-string-regexp@1.0.3, untildify@2.0.0, diff@1.4.0, text-table@0.2.0, debug@2.1.3, mem-fs@1.1.0, globby@1.2.0, grouped-queue@0.3.0)
├── configstore@0.3.2 (object-assign@2.0.0, xdg-basedir@1.0.1, osenv@0.1.0, graceful-fs@3.0.6, uuid@2.0.1, mkdirp@0.5.0, js-yaml@3.3.0)
├── insight@0.5.3 (object-assign@2.0.0, lodash.debounce@3.0.3, os-name@1.0.3, tough-cookie@0.12.1, request@2.55.0)
├── lodash@3.8.0
├── yeoman-doctor@1.3.2 (object-values@1.0.0, log-symbols@1.0.2, each-async@1.1.1, twig@0.7.2)
└── inquirer@0.8.3 (ansi-regex@1.1.1, cli-width@1.0.1, through@2.3.7, readline2@0.1.1, rx@2.5.2)
Sullys-MacBook-Pro:~ Sully$ yo
-bash: yo: command not found
并重新启动。该命令仍未找到。我做错了吗?
这是我的source .bash_profile
.bash_profile
这是我的完整$ PATH
# Add environment variable COCOS_CONSOLE_ROOT for cocos2d-x
export COCOS_CONSOLE_ROOT=/Users/Sully/Development/Libraries/cocos2d-x-3.5/tools/cocos2d-console/bin
export PATH=$COCOS_CONSOLE_ROOT:$PATH
# Add environment variable COCOS_TEMPLATES_ROOT for cocos2d-x
export COCOS_TEMPLATES_ROOT=/Users/Sully/Development/Libraries/cocos2d-x-3.5/templates
export PATH=$COCOS_TEMPLATES_ROOT:$PATH
# NPM
export BIN_ROOT=/usr/local/bin
export PATH=$BIN_ROOT:$PATH
答案 0 :(得分:1)
通过将~/.bash_profile
添加到Terminal.app
并重新启动$newIm='test.png';<br>
if(exif_imagetype($newIm)==IMAGETYPE_PNG) {<br>
$file_type="PNG";<br>
}elseif (exif_imagetype($newIm) ==IMAGETYPE_JPEG) {<br>
$file_type="JPG";<br>
}<br>
$pdf->Image($newIm,null,null,150,100,$file_type);<br>
来解决此问题。
答案 1 :(得分:0)
在成功安装所有内容后,我遇到了同样的问题,我使用以下方法解决了这个问题,创建了符合以下条件的yo,grunt,bower的符号链接:
对于Yo
praveen@praveen-lenovo:~$ sudo ln -s /home/praveen/.npm-global/bin/yo /usr/bin/yo
对于Grunt
praveen@praveen-lenovo:~$ sudo ln -s /home/praveen/.npm-global/bin/grunt /usr/bin/grunt
对于Bower
praveen@praveen-lenovo:~$ sudo ln -s /home/praveen/.npm-global/bin/bower /usr/bin/bower
在上面的命令中,公共路径/home/praveen/.npm-global/bin/
可能会根据您的系统文件夹结构而改变。