我无法从本地节点模块文件夹运行babel-cli。
我使用以下方法在本地节点模块文件夹中安装了babel-cli:
npm install babel-cli --save-dev
所以我不必在全球范围内安装babel。我可以看到它安装在node_modules中并添加到package.json文件中。
"devDependencies": {
"babel-cli": "^6.18.0"
}
当我使用命令
构建时babel app.js -o build/app.js
我收到一条消息说巴贝尔
The program 'babel' can be found in the following packages:
* babel-1.4.0
* openbabel
Try: sudo apt-get install <selected package>
我正在使用Ubuntu 14.4
我试图通过添加
来通过脚本访问babel "scripts": {
"babelversion": "babel --version",
}
当我运行命令时,npm run babelversion&#39;我得到了同样的错误
sh: 1: babel: Permission denied
和NPM错误,退出状态126
如何让当地的babel(没有全局安装)工作?
答案 0 :(得分:1)
我遇到了同样的问题,通过本地调用程序找到了解决方案,如下所示:
./node_modules/babel-cli/bin/babel.js app.js -o build/app.js
答案 1 :(得分:0)
如果您在Linux上授予所有者组执行权限。我检查了我的笔记本电脑,权限是这样的:644(即所有者的读写,读取组,读取其他)。所以我做了:chmod 744 babel。
https://en.wikipedia.org/wiki/Chmod
http://ss64.com/bash/chmod.html
使用sudo不会有所作为。
答案 2 :(得分:0)
我遇到了这个问题,请清除然后重新安装所有有效的东西:
>> npm cache clean --force
>> rm -rf node_modules
>> npm install
注意:它需要两个 force 命令,因此请确保只在愿意重新安装所有内容的存储库中尝试使用此命令。