Cannot run Visual Studio code script via symlink - shell

So, I built Visual Studio Code from source and intend to keep using it like that. But now everytime I want to open it I have to run a script from its directory. I made a symlink to that script in my /usr/local/bin but unfortunately when I run it it says this:
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
I perfectly understand that it cannot access some files, but I don't understand why. Are there any nuances regarding running electron apps?

Okay, guys. I think I solved this problem. When I ran code.sh via symlink it tried to find necessary files in the directories from my PATH variable. As I intended to run this script from anywhere but original folder they obviously wouldn't be found. So all I had to do was exporting original script directory to PATH.
As I didn't want to bloat my PATH I wrote a little helper script and made a symlink to it from /usr/local/bin/
Here's the code:
#!/bin/sh
export PATH=$PATH:/Users/work/Stuff/vscode/
cd /Users/work/Stuff/vscode/
./scripts/code.sh

Related

Error: Illegal characters in path in npm rimraf

I am getting an error while I tried to delete multiple directories using npm rimraf.
Error: Illegal characters in path
Command I run is rimraf **/lib/**
> ecommerce.ui#0.7.2 clean-libs
> rimraf **/lib/**
Error: Illegal characters in path.
at pathArg (C:\Users\SUDARANGA\AppData\Roaming\nvm\v18.9.0\node_modules\rimraf\dist\cjs\src\path-arg.js:45:33)
at C:\Users\SUDARANGA\AppData\Roaming\nvm\v18.9.0\node_modules\rimraf\dist\cjs\src\index.js:34:66
at Array.map (<anonymous>)
at C:\Users\SUDARANGA\AppData\Roaming\nvm\v18.9.0\node_modules\rimraf\dist\cjs\src\index.js:34:28
at main (C:\Users\SUDARANGA\AppData\Roaming\nvm\v18.9.0\node_modules\rimraf\dist\cjs\src\bin.js:134:11)
at Object.<anonymous> (C:\Users\SUDARANGA\AppData\Roaming\nvm\v18.9.0\node_modules\rimraf\dist\cjs\src\bin.js:143:5)
at Module._compile (node:internal/modules/cjs/loader:1119:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1173:10)
at Module.load (node:internal/modules/cjs/loader:997:32)
at Module._load (node:internal/modules/cjs/loader:838:12) {
path: 'C:\\source\\Ecommerce.UI\\**\\lib\\**',
code: 'EINVAL'
}
Version v4 of rimraf removed globbing support, but they might add it back as per rimraf/issues/249.
If you're using rimraf just for the command line usage (i.e. using it as an npm command and not using the javascript API), then I've found that del-cli seems to be a good cross-platform replacement.

How to fix on Mac OSX EACCES: permission denied...You don't have access to this file

I'm trying to make a new project with gatsby template running the command gatsby new website-public https://github.com/gatsbyjs/gatsby-starter-default in Terminal window, but I constantly getting this error:
gatsby new website-public https://github.com/gatsbyjs/gatsby-starter-default
Error: EACCES: permission denied, open '/Users/delilah/.config/gatsby/config.json'
You don't have access to this file.
at Object.openSync (node:fs:585:3)
at Object.readFileSync (node:fs:453:35)
at Ti._i.globalConfigPath.get all [as all] (/usr/local/lib/node_modules/gatsby-cli/node_modules/create-gatsby/lib/index.js:1:155965)
at new Ti._i.globalConfigPath (/usr/local/lib/node_modules/gatsby-cli/node_modules/create-gatsby/lib/index.js:1:155924)
at Ti (/usr/local/lib/node_modules/gatsby-cli/node_modules/create-gatsby/lib/index.js:1:155721)
at Object.<anonymous> (/usr/local/lib/node_modules/gatsby-cli/node_modules/create-gatsby/lib/index.js:1:486075)
at Module._compile (node:internal/modules/cjs/loader:1095:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1147:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
I have tried with following:
sudo chown -R whoami ~/.npm
sudo chown -R whoami
/usr/local/lib/node_modules
But nothing helps, I'm using Mac OSX.
If anyone has some idea, please share.
The error message says that /Users/delilah/.config/gatsby/config.json is the file you don't have access to, so that's the file you have to chown and/or chmod to fix, not paths you list as having tried.

Yarn.cmd vs Yarn

for the past 3 weeks yarn has worked just fine. Now randomly i can't use yarn anymore unless I use yarn.cmd start. Why does yarn require the ".cmd" all of a sudden.
If i use the normal yarn commands i get the following error:
$ yarn
module.js:549
throw err;
Error: Cannot find module 'C:\Users\Me\Desktop\CodeProject\material\client\yarn.js
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at boostrap_node.js:612:3
You are running with bash on Windows. You have another copy of yarn in your PATH, one with .cmd as extension and one with another extension. To find the offending copy of yarn, do:
$ which yarn
It depends on what you find but you're probably uninstalling something or changing your PATH environment variable.

Cordova 4.3.0 - build command returns error Cannot find module 'Q'

After updating cordova to version 4.3.0 the command:
cordova build
returns the following error:
module.js:340
throw err;
^
Error: Cannot find module 'Q'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Volumes/CaseSensitive/ios_projects/_Tests/testGruntCordova/testGruntCordova/platforms/ios/cordova/lib/check_reqs.js:25:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
ERROR building one of the platforms: Error: /Volumes/CaseSensitive/ios_projects/_Tests/testGruntCordova/testGruntCordova/platforms/ios/cordova/build: Command failed with exit code 8
You may not have the required environment or OS to build this project
Error: /Volumes/CaseSensitive/ios_projects/_Tests/testGruntCordova/testGruntCordova/platforms/ios/cordova/build: Command failed with exit code 8
at ChildProcess.whenDone (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:131:23)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:753:16)
at Process.ChildProcess._handle.onexit (child_process.js:820:5)
I have already tried to remove and add the platform ios but nothing changes.
I have tried to run:
sudo npm install -g cordova / sudo npm install cordova
sudo npm install -g Q / sudo npm install Q
but nothing changes.
Any help?
Thank you very much
There was a bug and I have released a patch to it:
Apache Cordova ios - Git Repository
This is a bug shown on case-sensitive systems such as Unix, Linux and some OS X (if set as case-sensitive).
So far, to fix it, you have to locate those files containing a line like this:
Q = require('Q')
You can locate the files while standing on your project directory using grep:
grep -HnrI "require('Q" *;
then, use any text editor to manually change the mentioned line to:
Q = require('q')
Alternatively you can edit the related files on a more straight forward way by running the following command on your project directory:
grep -rl "require('Q" * | xargs sed -i "" "s/'Q'/'q'/g";
The single line above searches and edits the files that need the change.
Removing and then re-adding the platform again also works:
cordova platform remove ios
cordova platform add ios
Now you can cordova build ios :)
As mentioned by MeV this was a bug.

Setting up a LESS file watcher in PHPStorm 6 using node.js on Windows?

I'm a recent convert to PHPStorm and absolutely loving it. I'm trying to get the 'File Watcher' to work with my LESS code, and I want it to use the lessc command. I have node.js installed and the command 'lessc' works from the windows command prompt, but it doesn't want to work within PHPStorm.
Here is my configuration for the file watcher:
When the file watcher runs, I get this error appear continuously:
An exception occurred while executing watcher 'LESS'. Watcher is
disabled. Fix it.: Cannot run program
"C:\Users\Jason\AppData\Roaming\npm\lessc" (in directory
"F:\Plan2Share_v1\public\css"): CreateProcess error=193, %1 is not a
valid Win32 application
As soon as I enable the watcher again, it somehow disables and throws me the above error again. I'm very new to node.js and PHPStorm. Any direction on where I might be going wrong would be greatly appreciated.
EDIT: Following #josh3736 's direction. I now get his error in the Run console of PHPStorm.
"C:\Program Files\nodejs\node.exe" C:\Users\Jason\AppData\Roaming\npm\lessc F:\Plan2Share_v1\public\css\style.less
C:\Users\Jason\AppData\Roaming\npm\lessc:2 basedir=`dirname "$0"`
^ SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
That error tells us that PHPStorm is calling CreateProcess, which can only start executables. It cannot run scripts/batch files, which is what lessc is. (PHPStorm would have to use ShellExecute for that.)
To work around this limitation, you'll have to specify the Node installation (C:\Program Files\nodejs\node.exe most likely) as the executable, and the arguments should probably be something like C:\Users\Jason\AppData\Roaming\npm\node_modules\less\bin\lessc $FileName$
Change Program: C:\Users\Jason\AppData\Roaming\npm\lessc.cmd
Change Arguments: --no-color $FileName$
Apply
Image: https://dl.dropboxusercontent.com/u/4287697/2014-09-26_11h25_29.png

Resources