【问题标题】:how to run script in brackets extension package.json?如何在括号扩展 package.json 中运行脚本?
【发布时间】:2017-08-23 17:18:56
【问题描述】:

安装我的扩展时,我想在 Brackets 扩展管理器中运行脚本。

在括号默认扩展“JavaScriptCodeHints”中找到此代码。

{
  "name": "brackets-javascript-code-hints",
  "dependencies": {
    "acorn": "3.3.0",
    "tern": "0.20.0"
},
  "scripts": {
    "postinstall": "node ./fix-acorn"
  }
}

同样使用“postinstall”:“node ./test”,但显示此错误消息。

npm-stderr: sh: node: command not found

npm WARN testExtensionInstaller@1.0.1 No description
npm WARN testExtensionInstaller@1.0.1 No repository field.
npm WARN testExtensionInstaller@1.0.1 No license field.
npm ERR! Darwin 16.7.0
npm ERR! argv "/Applications/Brackets.app/Contents/MacOS/Brackets-node" "/Applications/Brackets.app/Contents/www/node_modules/npm/bin/npm-cli.js" "install" "--production"
npm ERR! node v6.3.1
npm ERR! npm  v3.10.9
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! testExtensionInstaller@1.0.1 postinstall: `node ./test`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the testExtensionInstaller@1.0.1 postinstall script 'node ./test'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the testExtensionInstaller package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node ./test
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs testExtensionInstaller
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls testExtensionInstaller
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /private/var/folders/1y/bd63w8h51wzccq_zbw6804440000gn/T/bracketsPackage_117723-46419-zgk6x5.ki3sicc8fr/testExtensionInstaller/npm-debug.log

如何在Brackets扩展安装中使用node而不安装nodejs?

【问题讨论】:

    标签: node.js package.json adobe-brackets


    【解决方案1】:

    这与括号无关,您需要更新文件系统路径以包含节点

    您需要将安装 nodeJS 的位置 (C:\Program Files\nodejs) 添加到 PATH 环境变量中。为此,请按以下步骤操作:

    1. 使用全局搜索 Charm 搜索“环境变量”
    2. 点击“编辑系统环境变量”
    3. 点击对话框中的“环境变量”。
    4. 在“系统变量”框中,搜索路径并对其进行编辑以包含C:\Program Files\nodejs。确保它通过; 与任何其他路径分开。

    您必须重新启动所有当前打开的命令提示符才能生效。

    【讨论】:

    • 我知道。但默认扩展安装在没有 nodejs 和 PATH 环境的情况下。
    • 请通过使用扩展名执行以下文件检查节点的路径是否在括号-nodejs的运行环境中:console.log(process.env.PATH);
    • 它是默认扩展,所以安装了括号(内部扩展)。所以在构建括号之前我无法添加代码。 github.com/adobe/brackets/tree/master/src/extensions/default/… 是默认扩展 github url
    • 我正在阅读这些问题,有人建议delete Brackets completely and reinstall Brackets via the latest installer again.
    • 我的英文不太好,看来是被误会了。我想开发一个扩展,其中节点在默认扩展中的 package.json 之类的脚本中运行。默认扩展安装正确,但是在我的扩展中出现找不到节点的错误。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-26
    • 2020-03-04
    • 1970-01-01
    • 2020-05-10
    • 2020-04-15
    相关资源
    最近更新 更多