Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
329 views
in Technique[技术] by (71.8m points)

node.js - NPM -bash command not found

I am trying to run through nodeschool.io exercises. I am having trouble running their packages.

The first package I installed:

$ npm install -g learnyounode
$ learnyounode

Runs the package with the command learnyounode

Every other package on their site I tried installing and can't run the program with the proper command in the command line, ex:

$ npm install -g functional-javascript-workshop@latest
$ /Users/name/npm/bin/functional-javascript -> /Users/name/npm/lib/node_modules/functional-javascript-workshop/functional-javascript.js
/Users/name/npm/bin/functional-javascript-workshop -> /Users/name/npm/lib/node_modules/functional-javascript-workshop/functional-javascript.js
functional-javascript-workshop@0.0.27 /Users/name/npm/lib/node_modules/functional-javascript-workshop
├── lorem-ipsum@0.1.1 (inflection@1.2.7, optimist@0.3.7)
└── workshopper@0.7.2 (map-async@0.1.1, tuple-stream@0.0.2, split@0.2.10, through@2.3.6, mkdirp@0.3.5, colors-tmpl@0.1.0, xtend@2.1.2, terminal-menu@0.2.0, optimist@0.6.1, msee@0.1.1)

$ functional-javascript-workshop
$ -bash: functional-javascript-workshop: command not found

Here is a link to the package I am trying to install in the example: functional-javascript-workshop

As you can see, I am getting the message -bash - command not found

Looking at other posts with similar problems, I ran the following commands to see my path and where the packages are being saved:

$ which node
$ /usr/local/bin/node

$ which npm
$ /usr/local/bin/npm

$PATH 
$ Users/name/.rbenv/shims:/Users/name/.rbenv/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin: No such file or directory

Steps I tried:

  • Uninstall/Reinstall node using brew commands
  • global update npm's ($ npm update -g)

It looks like my node-modules are being installed at /Users/name/npm/lib/node_modules I'm not sure though how to give my command line access or a way of looking into that path for the command to start the program.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

The functional-javascript-workshop executable is in /Users/name/npm/bin, which is not in your PATH variable, add this to your .bashrc or .bash_profile file:

export PATH=$PATH:/Users/name/npm/bin

Then you should be able to run functional-javascript-workshop


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...