nodeclipse can't run package.json script targets - nodeclipse

with a simple package like
{
"name": "test",
"version": "0.1.0",
"description": "test",
"main": "hello-world-server.njs",
"scripts": {
"start": "node hello-world-server.js"
},
"repository": "",
"keywords": [
"node.js",
"eclipse",
"nodeclipse"
],
"author": "",
"license": "MIT",
"readmeFilename": "README.md"
}
i can run (from command line) :
npm start
and all is fine. but from eclipse (nodeclipse), with npm ... , from the run configurations, all I get is:
> test#0.1.0 start /Users/chrismarx/Documents/workspaces/yardmap-3.5.0/test
> node ./hello-world-server.js
execvp(): No such file or directory
anybody know how to fix this? i just installed nodeclipse into a fresh install, i believe i've got the latest version 0.15.1.201404300203

Usually in GUI select .js file, right-click Run As -> Node App.
Later can select from Run drop down menu
While npm start would be from command line.

In your case, you can right click on /bin/www -> Run As -> Node App.

Related

Yarn does not see workspaces

I have the following configuration in a root workspace. The strange thing is that for backend it works, but for frontend - doesn't, no matter how I rename this
{
"private": true,
"name": "root",
"workspaces": [
"packages/frontend",
"packages/backend"
],
"scripts": {
"client": "yarn workspace frontend start",
"client-test": "yarn workspace frontend test",
"server": "yarn workspace backend start",
"start": "conc --kill-others-on-fail \"yarn client\" \"yarn server\""
},
"devDependencies": {
"concurrently": "^7.6.0"
}
}
And it always says: $ yarn workspace frontend test
error Unknown workspace "frontend".
info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I tried to start from all directories, nothing works
The thing is that it does not matter how folders are called inside of "packages", the important thing is that package.json of each workspace should be called correspondingly:
{
"name": "frontend",
"version": "1.0.0",
"private": true,
...
}

How to automate Visual Studio Code startup?

I need to setup my development environment multiple times a day, I want to automate the process to a one-click solution.
The goal is to having a main script which opens up two VS Code instances, one for the frontend, one for the backend project.
The steps should be the following:
- open VS Code
- open Backend Project (located at e.g.: C:/myCompany/backend)
- run git pull
- open terminal
- run docker-compose up
- open split terminal
- run npm run start:dev
- open another vscode
- open terminal
- git pull
- open terminal
- run npm run start:dev
I am running windows, I can create very basic ps1 files, I know you can use terminal and run 'code' command to start an instance of VS Code. After that I don't find information what to do next.
I know there some kind of scripts you can run in Vs Code too, but I cannot put it all together.
There's a certain level of automation that can be achieved with VSCode's tooling itself.
Let's start with the backend part of the project. Inside C:/myCompany/backend create a folder .vscode and inside of it place two files: settings.json and tasks.json. They should be as follows:
// C:/myCompany/backend/.vscode/tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "git pull",
"type": "shell",
"command": "git pull",
"problemMatcher": [],
"runOptions": {
"runOn": "folderOpen"
}
},
{
"label": "docker-compose up",
"command": "docker-compose up",
"type": "shell",
"presentation": {
"reveal": "always",
"panel": "dedicated",
"group": "dev"
},
"group": "build",
"runOptions": {
"runOn": "folderOpen"
}
},
{
"label": "start:dev",
"type": "shell",
"command": "npm run start:dev",
"presentation": {
"panel": "dedicated",
"group": "dev"
},
"runOptions": {
"runOn": "folderOpen"
}
}
]
}
// C:/myCompany/backend/.vscode/settings.json
{
"task.allowAutomaticTasks": "on"
}
Similarly, under C:/myCompany/frontend create the same .vscode folder and the same two files under it; settings.json would stay the same, but tasks.json would be as follows:
// C:/myCompany/frontend/.vscode/tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "git pull",
"type": "shell",
"command": "git pull",
"problemMatcher": [],
"runOptions": {
"runOn": "folderOpen"
}
},
{
"label": "start:dev",
"type": "shell",
"command": "npm run start:dev",
"presentation": {
"panel": "dedicated",
"group": "dev"
},
"runOptions": {
"runOn": "folderOpen"
}
}
]
}
To finish things up, the powershell script would be as simple as this:
code C:\myCompany\backend
code C:\myCompany\frontend
In previous VSCode versions it was necessary to invoke workbench.action.tasks.manageAutomaticRunning and then to choose Allow Automatic Tasks in Folder once for each folder, but that doesn't seem to be the case any more (the setting in settings.json seems to suffice).
For further customisation (e.g. task execution order and dependency), you can look at the documentation: https://code.visualstudio.com/Docs/editor/tasks. You can also experiment with running git pull right from the powershell script instead of the VSCode tasks.

unable to add package in yarn workspace monorepo

I am trying to import components in a shared package in a monorepo, but am unable to do so.
I have the following package.json files under the root of a repo that I want to run as a monorepo. /apps/billing is a create-react-app. /apps/shared is going to contain components for billing and other apps.
/package.json
{
"name": "root",
"version": "1.0.0",
"private": true,
"description": "",
"main": "index.js",
"workspaces": [
"apps/*"
],
"scripts": {
"billing": "cd apps/billing; yarn start"
},
"author": "",
"license": "ISC",
"dependencies": {}
}
/apps/billing/package.json
{
"name": "#root/billing",
"version": "0.1.0",
"private": true,
"dependencies": {
<snip>
},
}
/apps/billing/shared.json
{
"name": "#root/shared",
"version": "1.0.0",
"main": "index.js",
"license": "MIT"
}
In the /apps/billing directory I tried to run yarn add #root/shared and get the following output:
error An unexpected error occurred: "https://registry.yarnpkg.com/#root%2fshared: Not found".
In billing, when I try to import a component from shared
import Button from '#root/shared/components/Button';
I get
Module not found: Can't resolve '#root/shared/components/Button'
Are there additional steps to setup a yarn monorepo?
It's wrong structure for monorepo.
Also you've wrongly named /apps/billing/shared.json it should be package.json instead of shared.json
At first your package.json in the root folder should be named eg. #name-of-your-app/monorepo
then packages under your root.
fe. in apps/billing
{
"name": "#name-of-your-app/billing-app",
"version": "0.1.0",
"private": true,
"dependencies": {
// any dependencies
},
then your shared components:
each should be in its own directory
each should have its own package.json
Let's say that you have shared/Button
then Button should be in its own directory and contain package.json
eg. of shared/Button/package.json/
{
"name": "#name-of-your-app/button",
"version": "0.1.0",
"private": true,
"dependencies": {
// any dependencies
},
and if you want to use this button in your billing-app
then you should at first add this as dependency IMPORTANT watchout for version of your button in package.json, the same should be installed as dependency in your app, otherwise it will finish up with bunch of errors.
-Then when you want to import this button in any component under your billing-app then import should look like this:
import Button from '#name-of-your-app/button'
You can read more about workspaces here:
yarn workspaces
Also I recommend to read more about monorepo structure fe. here

Why I'm not able to run npm scripts? [duplicate]

I was running an Electron project, and everything worked just fine. But now when I run any of the scripts in my package.json (including npm start), it just escapes a line and doesn't do anything.
My package.json:
{
"name": "interclip-desktop",
"version": "0.0.7",
"description": "Interclip for desktop",
"repository": "https://github.com/aperta-principium/Interclip-desktop",
"main": "main.js",
"scripts": {
"start": "electron .",
"package-mac": "electron-packager . --overwrite --asar=true --platform=darwin --arch=x64 --icon=assets/icons/mac/icon.icns --prune=true --out=release-builds",
"package-win": "electron-packager . Interclip --overwrite --platform=win32 --arch=ia32 --icon=assets/icons/win/icon.ico --prune=true --out=release-builds --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName=\"Interclip\"",
"package-linux": "electron-packager . Interclip --overwrite --asar=true --platform=linux --arch=x64 --icon=assets/icons/png/icon.png --prune=true --out=release-builds",
"win-install": "node installers/windows/createinstaller.js",
"postinstall": "electron-builder install-app-deps",
"build": "electron-builder --linux",
"release": "electron-builder --linux --publish always"
},
"keywords": [
"Desktop",
"Interclip"
],
"author": "Filip Troníček",
"license": "MIT",
"devDependencies": {
"electron": "^7.1.2",
"electron-builder": "^22.1.0",
"electron-installer-dmg": "^3.0.0",
"electron-packager": "^14.1.1",
"electron-reload": "^1.5.0",
"electron-winstaller": "^4.0.0"
},
"dependencies": {
"axios": "^0.19.0",
"mousetrap": "^1.6.3"
},
"build": {
"appId": "com.aperta-principium.interclip",
"productName": "Interclip",
"mac": {
"category": "public.app-category.utilities"
},
"dmg": {
"icon": false
},
"linux": {
"target": [
"AppImage"
],
"category": "Utility"
}
}
}
I tried updating NPM, didn't work. When I tried in different projects, also doesn't work.
Thanks in advance
npm has a ignore-scripts configuration key. It's expected value is a Boolean and it's set to false by default.
Perhaps it has inadvertently been set to true.
To get/set the ignore-scripts configuration you can utilize the npm-config command:
Check its current setting by running:
npm config get ignore-scripts
If the aforementioned command returns true then reset it to false by running:
npm config set ignore-scripts false
If you are using an integrated terminal (such as the VsCode integrated terminal) try running your npm "run dev' command from your PowerShell (or cmd) terminal. This error arises as a result of your integrated terminal not recognizing your command (especially if you created your app with a git bash terminal).
Try this, and I hope it helps someone cause it always works for me. Cheers!!!

procfile no changing from web to worker

I'm trying to Host my bot "chompbot" in Heroku.
But when i change Procfile from web to worker, does not change anything.
I've tried
Here is my package.json
"name": "chompbot",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"discord.js": "^11.5.1",
"mysql": "^2.17.1"
}
}
And here is my Procfile
worker: index.js
When i commit and push, anything happens on "Web", and do not appears "Worker" option
( Ps.: The MySql database is fully working on cloud, so, can't be the dependencies )
Can someone help me to change from Web to Worker?
http://prntscr.com/pb21qs
Your worker should be the script that starts you server, index.js is only the file name. What you want to do is to use your npm start script instead of index.js

Resources