如何在括号扩展package.json中运行脚本?

时间:2017-08-23 08:26:20

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

我希望在安装我的扩展程序时在Brackets Extension管理器中运行脚本。

在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扩展安装中使用没有安装nodejs的节点?

1 个答案:

答案 0 :(得分:0)

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

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

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

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