简体   繁体   English

-bash:jspm:找不到命令

[英]-bash: jspm: command not found

I am trying to npm install JSPM, so that I can run jspm init, for instance. 我正在尝试npm安装JSPM,以便可以运行jspm init。

npm install -g jspm

is unfortunately not enabling the jspm cli. 不幸的是没有启用jspm cli。

npm install jspm --save-dev

in project root, isn't doing the trick either. 在项目根目录中,也没有达到目的。

node -v = v6.2.1
npm -v = 3.9.3
echo $PATH = /usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/usr/local/git/bin:/usr/local/bin:/usr/local/git/bin:/usr/local/bin

The error 错误

-bash: jspm: command not found

occurs after running jspm init, or jspm. 在运行jspm init或jspm之后发生。

OS: OS X El Capitan version 10.11.3 作业系统:OS X El Capitan版本10.11.3

Symlink when running an npm install -g jspm 运行npm install -g jspm时的符号链接

/Users/user/.npm-packages/bin/jspm -> /Users/user/.npm-packages/lib/node_modules/jspm/jspm.js
/Users/user/.npm-packages/lib

My thanks as always :) 我一如既往的感谢:)

You might need to add it to your environment variables. 您可能需要将其添加到环境变量中。

In windows add the following line on your path environment variables: Windows中 ,在路径环境变量上添加以下行:

%appdata%\npm

In OS X it might be something like (I am not sure about the exact syntax but it might give you some direction): OS X中 ,可能类似于(我不确定确切的语法,但可能会为您提供一些指导):

~/.bash_profile
export PATH=$PATH:.

I fixed this by running the installation as sudo: 我通过将安装作为sudo运行来解决了这个问题:

npm install jspm -g

A lot of the other posts had elaborate workarounds involving NVM, editing permissions on bash files, etc. but I'm too busy and just need this to work. 许多其他文章都涉及NVM,对bash文件的编辑权限等的详尽解决方法,但是我太忙了,只需要这样做即可。 😉 😉

In the end after thinking through the answer here is what I did to solve this problem. 最后,在仔细思考答案之后,我做了些什么来解决这个问题。

ONE

I searched around and found that my $PATH variable was located here ~/.profile 我四处搜索,发现我的$ PATH变量位于此处〜/ .profile

so running 这么跑

emacs ~/.profile 

I was able to edit path directly from my terminal(Iterm). 我可以直接从终端(Iterm)编辑路径。

TWO

I made sure to remove any duplicate filepaths and to make sure that all default paths went first, so that my local paths would override them. 我确保删除所有重复的文件路径,并确保所有默认路径排在最前面,以便我的本地路径覆盖它们。 It ended up looking like this 最终看起来像这样

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/usr/local/sbin:/usr/local/git/bin:/usr/local/mysql/bin:/usr/local/bin

THREE

In addition, I realized that if any path was missing it would be the 此外,我意识到,如果缺少任何路径,那将是

/Users/user/.npm-packages/bin 

filepath. 文件路径。 I added it, where user would be your name. 我添加了它,用户将是您的名字。 In my case charlie, so 以我为例,查理

/Users/charlie/.npm-packages/bin. 

That did it, running jspm worked as expected. 做到了,运行jspm可以按预期工作。 NOICE! 注意!

FINAL $PATH 最终$ PATH

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/git/bin:/usr/local/sbin:/usr/local/git/bin:/usr/local/mysql/bin:/usr/local/bin:/Users/charlie/.npm-packages/bin

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM