Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/unix/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Shell 无法通过符号链接运行Visual Studio代码脚本_Shell_Unix_Path_Visual Studio Code_Electron - Fatal编程技术网

Shell 无法通过符号链接运行Visual Studio代码脚本

Shell 无法通过符号链接运行Visual Studio代码脚本,shell,unix,path,visual-studio-code,electron,Shell,Unix,Path,Visual Studio Code,Electron,所以,我从源代码构建了VisualStudio代码,并打算继续这样使用它。但现在每次我想打开它,我都必须从它的目录中运行一个脚本。我在我的/usr/local/bin中创建了一个指向该脚本的符号链接,但不幸的是,当我运行它时,它会显示以下内容: device:scripts work$ sudo code Password: module.js:550 throw err; ^ Error: Cannot find module './product.json' at

所以,我从源代码构建了VisualStudio代码,并打算继续这样使用它。但现在每次我想打开它,我都必须从它的目录中运行一个脚本。我在我的/usr/local/bin中创建了一个指向该脚本的符号链接,但不幸的是,当我运行它时,它会显示以下内容:

device:scripts work$ sudo code
Password:
module.js:550
    throw err;
    ^

Error: Cannot find module './product.json'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at [eval]:1:1
    at ContextifyScript.Script.runInThisContext (vm.js:50:33)
    at Object.runInThisContext (vm.js:139:38)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (module.js:653:30)
    at evalScript (bootstrap_node.js:479:27)
module.js:550
    throw err;
    ^

Error: Cannot find module '/usr/local/build/lib/electron.js'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3
/usr/local/bin/code: line 29: ./node_modules/.bin/gulp: No such file or directory
module.js:550
    throw err;
    ^

Error: Cannot find module '/usr/local/build/lib/builtInExtensions.js'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Function.Module.runMain (module.js:694:10)
    at startup (bootstrap_node.js:204:16)
    at bootstrap_node.js:625:3
/usr/local/bin/code: line 41: ./node_modules/.bin/gulp: No such file or directory
/usr/local/bin/code: line 50: /usr/local/.build/electron/.app/Contents/MacOS/Electron: No such file or directory
/usr/local/bin/code: line 50: exec: /usr/local/.build/electron/.app/Contents/MacOS/Electron: cannot execute: No such file or directory
设备:脚本工作$sudo代码
密码:
module.js:550
犯错误;
^
错误:找不到模块“./product.json”
在Function.Module.\u解析文件名(Module.js:548:15)
在Function.Module.\u加载(Module.js:475:25)
at Module.require(Module.js:597:17)
根据需要(内部/module.js:11:18)
在[评估]:1:1
在ContextifyScript.Script.runInThisContext(vm.js:50:33)
在Object.runInThisContext(vm.js:139:38)
反对。([eval]-包装:6:22)
编译(Module.js:653:30)
在evalScript(bootstrap_node.js:479:27)
module.js:550
犯错误;
^
错误:找不到模块“/usr/local/build/lib/electron.js”
在Function.Module.\u解析文件名(Module.js:548:15)
在Function.Module.\u加载(Module.js:475:25)
位于Function.Module.runMain(Module.js:694:10)
启动时(bootstrap_node.js:204:16)
在bootstrap_node.js:625:3
/usr/local/bin/code:第29行:./node_modules/.bin/gulp:没有这样的文件或目录
module.js:550
犯错误;
^
错误:找不到模块“/usr/local/build/lib/builtInExtensions.js”
在Function.Module.\u解析文件名(Module.js:548:15)
在Function.Module.\u加载(Module.js:475:25)
位于Function.Module.runMain(Module.js:694:10)
启动时(bootstrap_node.js:204:16)
在bootstrap_node.js:625:3
/usr/local/bin/code:第41行:./node_modules/.bin/gulp:没有这样的文件或目录
/usr/local/bin/code:line 50:/usr/local/.build/electron/.app/Contents/MacOS/electron:没有这样的文件或目录
/usr/local/bin/code:第50行:exec:/usr/local/.build/electron/.app/Contents/MacOS/electron:无法执行:没有这样的文件或目录

我完全理解它无法访问某些文件,但我不明白为什么。运行电子应用程序有什么细微差别吗?

好的,伙计们。我想我解决了这个问题。当我通过symlink运行code.sh时,它试图从PATH变量的目录中查找必要的文件。由于我打算从原始文件夹以外的任何地方运行此脚本,显然找不到它们。所以我所要做的就是将原始脚本目录导出到PATH。 因为我不想让我的路径膨胀,所以我编写了一个小助手脚本,并从/usr/local/bin创建了一个指向它的符号链接/ 代码如下:

#!/bin/sh
export PATH=$PATH:/Users/work/Stuff/vscode/
cd /Users/work/Stuff/vscode/
./scripts/code.sh