How to fix gulp windows script host error in vscode - javascript

Gulp watch task runner error. It results in a windows script host error.
I've already tried to change the file task.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"command": "gulp",
"isShellCommand": true,
"args": [
"--no-color"
],
"tasks": [
{
"taskName": "scripts",
"isBuildCommand": true,
"showOutput": "always"
},
{
"taskName": "sass",
"isBuildCommand": true,
"showOutput": "always"
},
{
"taskName": "watch",
"isBuildCommand": true,
"showOutput": "always"
}
]
}

It looks like you are using older syntax. I don't believe taskname is supported anymore for example.
Here is a tasks.json file that I use and both methods of calling gulp commands work. (You mentioned task.json, I assume that is a typo, it is tasks.json)
{
"version": "2.0.0",
"tasks": [
{
"label": "Start server and process files",
"command": "gulp",
"args": [
"sync"
],
"type": "shell",
"options": {
"cwd": "${workspaceRoot}"
}
},
{
"label": "Gulp: Start server only",
"type": "gulp",
"task": "serve",
"problemMatcher": []
},
{
"label": "Gulp: watch",
"type": "gulp",
"task": "watch",
"problemMatcher": []
}
}
It looks like you also want:
"group": "build",
in each of your tasks - that replaces the isBuildCommand syntax you used above.
And:
"presentation": {
"reveal": "always",
},
instead of the showoutput syntax.
See migrating to tasks 2.0 documentation.

Related

How to properly delay the loading of a Node/Express API using tasks.json in VS Code

I've got a microservices project which I debug in a single VS Code instance. I use Compounds in launch.json to launch/debug.
There's a "Metadata" service which all other services are dependent on, so it needs to be running before any others start up.
I had this solved and it has worked swimmingly for me, for the last 10 months, but it spontaneously broke, recently.
Here's what I've got.
launch.json:
Compound:
{
"name": "API-only",
"stopAll": true,
"configurations": [
"Metadata API",
"Auth API"
]
}
...and the individual API configs in the compound:
{
"type": "node",
"request": "launch",
"name": "Metadata API",
"program": "${workspaceFolder}/metadata-api/bin/www",
"envFile": "${workspaceFolder}/metadata-api/.env",
"skipFiles": [
"<node_internals>/**/*.js",
"${workspaceRoot}/node_modules/**/*.js"
],
"presentation": {
"hidden": false,
"group": "apis",
"order": 1
}
},
{
"type": "node",
"request": "launch",
"name": "Auth API",
"program": "${workspaceFolder}/auth-api/bin/www",
"envFile": "${workspaceFolder}/auth-api/.env",
"skipFiles": [
"<node_internals>/**/*.js",
"${workspaceRoot}/node_modules/**/*.js"
],
"preLaunchTask": "Preload Delay",
"presentation": {
"hidden": true,
"group": "",
"order": 1
}
}
You can see the "preLaunchTask" is set in Auth API but not Metadata API. Here's that:
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "Preload Delay",
"type": "shell",
"command": "sleep 3",
"windows": {
"command": "ping 127.0.0.1 -n 3 > nul"
},
"group": "none",
"presentation": {
"reveal": "silent",
"panel": "shared",
"revealProblems": "onProblem"
}
}
]
}
I used to be able to watch Metadata load first, then Auth after 3 seconds, in the VSC Call Stack panel. Now, they both show up immediately and often, Auth fails because it's no longer respecting the delay to wait for Metadata to load first, so it can make calls to it and load, itself.
Sure enough, if I manually start Metadata first, or manually pause Auth to wait for Metadata to load, it works every time.
None of this configuration has changed in over 10 months now, so I suspect a recent VSC update had to have broken this? Is there another way? I'm not finding much to go on, out there.
I went through the VS Code documentation and found two problems with your tasks.json.
1-You need to create two different tasks separately for the above mentioned scenario like this e.g
{
"version": "2.0.0",
"tasks": [{
"label": "Client Build",
"command": "gulp",
"args": ["build"],
"options": {
"cwd": "${workspaceFolder}/client"
}
},
{
"label": "Server Build",
"command": "gulp",
"args": ["build"],
"options": {
"cwd": "${workspaceFolder}/server"
}
},
{
"label": "Build",
"dependsOn": ["Client Build", "Server Build"]
}
]
}
2- You need to set "dependsOrder": "sequence" and configure dependencies like e.g.
{
"label": "One",
"type": "shell",
"command": "echo Hello ",
"dependsOrder": "sequence",
"dependsOn": ["Two", "Three"]
}
Find out More about compound tasks?
Good Luck!

Problem encountered on OTA update in EXPO React Native App

I'm having a problem with OTA updates from EXPO. Indeed, I have an application in which I have configured the updates via EAS and modified the app.json file in order to take the updates into account. Also I rebuilt the application and installed it. I try since, to make remote updates; unable to get the result of the update the application remains exactly the same.
This is my app.json:
{
"expo": {
"name": "xxxxxx",
"slug": "xxxxxx",
"version": "0.1.8",
"orientation": "portrait",
"icon": "./assets/icon.png",
"splash": {
"image": "./assets/xxxxxx.png",
"resizeMode": "contain",
"backgroundColor": "#ffffff"
},
"updates": {
"fallbackToCacheTimeout": 300000,
"url": "https://u.expo.dev/8xxxxxxxxxxxxxxxxxxxxxxxxx"
},
"assetBundlePatterns": [
"**/*"
],
"ios": {
"supportsTablet": true
},
"android": {
"package": "com.xxxxxx.xxxxxx",
"adaptiveIcon": {
"foregroundImage": "./assets/icon.png",
"backgroundColor": "#FFFFFF"
},
"intentFilters": [
{
"action": "MAIN",
"data": {},
"category": [
"LEANBACK_LAUNCHER",
"LAUNCHER"
]
}
]
},
"androidNavigationBar": {
"visible": "sticky-immersive"
},
"androidStatusBar": {
"hidden": true
},
"web": {
"favicon": "./assets/logo-square.png"
},
"extra": {
"eas": {
"projectId": "8xxxxxxxxxxxxxxxxxxxxxxxx"
}
},
"runtimeVersion": {
"policy": "sdkVersion"
}
}
}
I've tried to modify the fallbackToCacheTimeout ... nothing. Also, i've tried to prebuild the app and put the version of the SDK in the app.json and AndroidManifest, nothing too.
Any ideas?

No symbols have been loaded for this document. Can't debug Javascript in Visual Studio Code

I'm working on a project that has a C# backend but the frontend is in React and Javascript. Debugging the C# works fine. When I try to debug the Javascript, it says 'No symbols have been loaded for this document'. Note that this is in Visual Studio Code not Visual Studio.
It's a huge project, so I'd like to place breakpoints and debug the code in Visual Studio Code rather than in Chrome tools.
I installed the 'Debugger for Chrome' VS Code extension, then I set my launch.json to be this:
{
"version": "0.2.0",
"configurations": [
{
"name": "WebApp Chrome Debug",
"type": "chrome",
"request": "launch",
"url": "http://localhost:5000",
"webRoot": "${workspaceFolder}/Bob/WebApp",
"sourceMapPathOverrides": {
"/*": "/__vscode-remote-uri__/*",
}
},
{
"name": "Launch WebApp (console)",
"type": "coreclr",
"request": "launch",
"preLaunchTask": "build",
"program": "${workspaceFolder}/Bob/WebApp/bin/Debug/WebApp.dll",
"args": [],
"cwd": "${workspaceFolder}/Bob/WebApp",
"console": "externalTerminal",
"internalConsoleOptions": "openOnSessionStart",
"stopAtEntry": false,
"launchBrowser": {
"enabled": true,
"args": "${auto-detect-url}",
"windows": {
"command": "cmd.exe",
"args": "/C start ${auto-detect-url}"
},
"osx": {
"command": "open"
},
"linux": {
"command": "xdg-open"
}
}
}
]
}
First I debug using the Launch WebApp (console) configuration:
Once that's launched, I run the 'WebApp Chrome Debug' configuration the same way:
Debugging:

Modify json object from file and keep structure

We have a json with object like following
JSON Before
// comment 1
{
"version": "2.0.0",
"tasks": [{
"type": "task1",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"aaa": "never"
}
}]
}
// comment 2
JSON After
Now I want to add a new object a new task (task 2)
// comment 1
{
"version": "2.0.0",
"tasks": [{
"type": "task1",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"aaa": "never"
}
},
{
"type": "task2",
"script": "watch",
"problemMatcher": "$tsh",
"isBackground": true,
"presentation": {
"aaa": "never"
}
}
]
}
// comment 2
The trick here, that I need to update the object without changing the structure, lines or comment. I try with jsonParse and it doesnt works
Is it possible in javascript/nodejs ?
I would suggest checking out the comment-json package, this is what it is designed to do, you shouldn't need to roll your own for this.
You can parse the JSON, then add the new task and write to your new file:
const { parse, stringify} = require("comment-json");
const fs = require("fs");
const taskFile = parse(fs.readFileSync("./input.json", "utf8"));
let taskToAdd = {
"type": "task2",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"aaa": "never"
}
};
taskFile.tasks.push(taskToAdd);
fs.writeFileSync("./output.json", stringify(taskFile, null, 4));
input.json
// comment 1
{
"version": "2.0.0",
"tasks": [{
"type": "task1",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"aaa": "never"
}
}]
}
// comment 2
Of course, if you wish to modify the JSON file in place, simply set the input and output filenames to the same value.

Why does React.js sometimes not let me use `debugger`

Sometimes I can put debugger; statements in my React components and it works, and sometimes it doesn't. For instance, I am calling my react component like this:
<script type="text/javascript">
debugger;
var nav = React.createElement(SubLocationSelector, {instanceID: #Model.InstanceID, locationID: #Model.LocationID, OnSublocationSelected: function(id, fullPath) {alert("ID: " + id + "; FullPath: " + fullPath);}}, null);
ReactDOM.render(nav, document.getElementById("drill-down-nav"));
</script>
and its debugger point gets hit. However inside the React component:
class SubLocationSelector extends React.Component{
constructor(props) {
debugger;
super(props);
this.model = new SubLocationSelectorViewModel();
this.model.loadSubLocations(this.props.locationID);
}
componentWillReceiveProps(nextProps) {
debugger;
if(nextProps.locationID != this.props.locationID){
this.model.loadSubLocations(nextProps.locationID)
}
}
render() {
debugger;
return (
<ViewModelBinder model={this.model}>
<SublocationSelectorDisplay model={this.model}
OnSublocationSelected={this.props.OnSublocationSelected} />
</ViewModelBinder>
)
}
}
none of these debugger points get hit if I run the code in Chrome with devtools open. I haven't yet isolated why some of my react components work with debugger and some don't, but I'm pretty confident it has to do with React.
Furthermore: is there a way to fix this behavior?
EDIT:
It's been suggested that this may be a culprit of a babel plugin such as remove-debugger. Here are the babel plugins listed by npm ls:
I don't have a .babelrc file or a package.json.
Searching for remove-debugger in my entire solution gets no results.
EDIT2:
There are two different package.jsons that might be used by babel:
{
"_args": [
[
{
"raw": "babel-runtime#^6.20.0",
"scope": null,
"escapedName": "babel-runtime",
"name": "babel-runtime",
"rawSpec": "^6.20.0",
"spec": ">=6.20.0 <7.0.0",
"type": "range"
},
"C:\\develop\\trakref\\node_modules\\babel-traverse"
]
],
"_from": "babel-runtime#>=6.20.0 <7.0.0",
"_id": "babel-runtime#6.20.0",
"_inCache": true,
"_location": "/babel-runtime",
"_nodeVersion": "6.9.0",
"_npmOperationalInternal": {
"host": "packages-12-west.internal.npmjs.com",
"tmp": "tmp/babel-runtime-6.20.0.tgz_1481239547266_0.8724558432586491"
},
"_npmUser": {
"name": "hzoo",
"email": "hi#henryzoo.com"
},
"_npmVersion": "3.10.8",
"_phantomChildren": {},
"_requested": {
"raw": "babel-runtime#^6.20.0",
"scope": null,
"escapedName": "babel-runtime",
"name": "babel-runtime",
"rawSpec": "^6.20.0",
"spec": ">=6.20.0 <7.0.0",
"type": "range"
},
"_requiredBy": [
"/babel-messages",
"/babel-traverse",
"/babel-types"
],
"_resolved": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.20.0.tgz",
"_shasum": "87300bdcf4cd770f09bf0048c64204e17806d16f",
"_shrinkwrap": null,
"_spec": "babel-runtime#^6.20.0",
"_where": "C:\\develop\\trakref\\node_modules\\babel-traverse",
"author": {
"name": "Sebastian McKenzie",
"email": "sebmck#gmail.com"
},
"dependencies": {
"core-js": "^2.4.0",
"regenerator-runtime": "^0.10.0"
},
"description": "babel selfContained runtime",
"devDependencies": {
"babel-helpers": "^6.6.0",
"babel-plugin-transform-runtime": "^6.9.0"
},
"directories": {},
"dist": {
"shasum": "87300bdcf4cd770f09bf0048c64204e17806d16f",
"tarball": "https://registry.npmjs.org/babel-runtime/-/babel-runtime-6.20.0.tgz"
},
"license": "MIT",
"maintainers": [
{
"name": "amasad",
"email": "amjad.masad#gmail.com"
},
{
"name": "hzoo",
"email": "hi#henryzoo.com"
},
{
"name": "jmm",
"email": "npm-public#jessemccarthy.net"
},
{
"name": "loganfsmyth",
"email": "loganfsmyth#gmail.com"
},
{
"name": "sebmck",
"email": "sebmck#gmail.com"
}
],
"name": "babel-runtime",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "https://github.com/babel/babel/tree/master/packages/babel-runtime"
},
"scripts": {},
"version": "6.20.0"
}
and this one:
{
"_args": [
[
{
"raw": "core-js#^2.4.0",
"scope": null,
"escapedName": "core-js",
"name": "core-js",
"rawSpec": "^2.4.0",
"spec": ">=2.4.0 <3.0.0",
"type": "range"
},
"C:\\develop\\trakref\\node_modules\\babel-runtime"
]
],
"_from": "core-js#>=2.4.0 <3.0.0",
"_id": "core-js#2.4.1",
"_inCache": true,
"_location": "/babel-runtime/core-js",
"_nodeVersion": "6.2.2",
"_npmOperationalInternal": {
"host": "packages-16-east.internal.npmjs.com",
"tmp": "tmp/core-js-2.4.1.tgz_1468791807265_0.5941079026088119"
},
"_npmUser": {
"name": "zloirock",
"email": "zloirock#zloirock.ru"
},
"_npmVersion": "3.9.5",
"_phantomChildren": {},
"_requested": {
"raw": "core-js#^2.4.0",
"scope": null,
"escapedName": "core-js",
"name": "core-js",
"rawSpec": "^2.4.0",
"spec": ">=2.4.0 <3.0.0",
"type": "range"
},
"_requiredBy": [
"/babel-runtime"
],
"_resolved": "https://registry.npmjs.org/core-js/-/core-js-2.4.1.tgz",
"_shasum": "4de911e667b0eae9124e34254b53aea6fc618d3e",
"_shrinkwrap": null,
"_spec": "core-js#^2.4.0",
"_where": "C:\\develop\\trakref\\node_modules\\babel-runtime",
"bugs": {
"url": "https://github.com/zloirock/core-js/issues"
},
"dependencies": {},
"description": "Standard library",
"devDependencies": {
"LiveScript": "1.3.x",
"es-observable-tests": "0.2.x",
"eslint": "3.1.x",
"grunt": "1.0.x",
"grunt-cli": "1.2.x",
"grunt-contrib-clean": "1.0.x",
"grunt-contrib-copy": "1.0.x",
"grunt-contrib-uglify": "1.0.x",
"grunt-contrib-watch": "1.0.x",
"grunt-karma": "2.0.x",
"grunt-livescript": "0.6.x",
"karma": "1.1.x",
"karma-chrome-launcher": "1.0.x",
"karma-firefox-launcher": "1.0.x",
"karma-ie-launcher": "1.0.x",
"karma-phantomjs-launcher": "1.0.x",
"karma-qunit": "1.1.x",
"phantomjs-prebuilt": "2.1.x",
"promises-aplus-tests": "2.1.x",
"qunitjs": "2.0.x",
"temp": "0.8.x",
"webpack": "1.13.x"
},
"directories": {},
"dist": {
"shasum": "4de911e667b0eae9124e34254b53aea6fc618d3e",
"tarball": "https://registry.npmjs.org/core-js/-/core-js-2.4.1.tgz"
},
"gitHead": "5e106f64c726edf2849f0babc9096ce6664b7368",
"homepage": "https://github.com/zloirock/core-js#readme",
"keywords": [
"ES3",
"ECMAScript 3",
"ES5",
"ECMAScript 5",
"ES6",
"ES2015",
"ECMAScript 6",
"ECMAScript 2015",
"ES7",
"ES2016",
"ECMAScript 7",
"ECMAScript 2016",
"Harmony",
"Strawman",
"Map",
"Set",
"WeakMap",
"WeakSet",
"Promise",
"Symbol",
"TypedArray",
"setImmediate",
"Dict",
"polyfill",
"shim"
],
"license": "MIT",
"main": "index.js",
"maintainers": [
{
"name": "zloirock",
"email": "zloirock#zloirock.ru"
}
],
"name": "core-js",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/zloirock/core-js.git"
},
"scripts": {
"grunt": "grunt",
"lint": "eslint es5 es6 es7 stage web core fn modules",
"observables-tests": "node tests/observables/adapter && node tests/observables/adapter-library",
"promises-tests": "promises-aplus-tests tests/promises-aplus/adapter",
"test": "npm run lint && npm run grunt livescript client karma:default && npm run grunt library karma:library && npm run promises-tests && npm run observables-tests && lsc tests/commonjs"
},
"version": "2.4.1"
}
Try to replace debugger with eval('debugger'), babel will not transform the string value.

Categories