Angular2 : concurrent is not recognized as internal or external command - node.js

While running server for angular2 using npm start is giving error that concurrent is not recognized as internal or external command, why is it happens these kind of error
here is package.json:
{
"name": "contactlistapp",
"version": "1.0.0",
"description": "The app",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"tsc": "./node_modules/.bin/tsc",
"tsc:w": "./node_modules/.bin/tsc -w",
"serve": "./node_modules/.bin/live-server --host=localhost --port=3000 .",
"start": "concurrent \"npm run tsc:w\" \"npm run serve\" "
},
"author": "Sarah",
"license": "ISC",
"dependencies": {
"express": "^4.13.3",
"angular2": "2.0.0-beta.0",
"systemjs": "0.19.6",
"es6-promise": "^3.0.2",
"es6-shim": "^0.33.3",
"reflect-metadata": "0.1.2",
"rxjs": "5.0.0-beta.0",
"zone.js": "0.5.10"
},
"devDependencies": {
"concurrently": "^1.0.0",
"lite-server": "^1.3.1",
"typescript": "^1.7.3"
}
}
structure of the project is there is node_module and typings folder there is app.ts file for server(empty only express is imported), and component.ts(and their .js), tsconfig.json

concurrent is not recognized as internal or external command
Must likely you haven't ran npm install since you added the "concurrently": "^1.0.0" dependency.
live-server is not recognized as external or internal command
You are installing the lite-server :
"lite-server": "^1.3.1"
yet you are calling the live-server:
"serve": "./node_modules/.bin/live-server --host=localhost --port=3000 ."
call lite-server instead.

Related

Jovo Could not resolve “vscode” error when I try to deploy

I’m trying to deploy my Jovo project to AWS Lambda using the command: “jovo deploy:code serverless” and I get “Could not resolve “vscode” error” at various locations in the node_modules folder.
Example:
X [ERROR] Could not resolve “vscode”`
node_modules/#alexa/acdl/dist/cjs/extension.js:30:27: 30 │ const vscode = require(“vscode”);
╵ ~~~~~~~~`
You can mark the path “vscode” as external to exclude it from the bundle, ``which will remove this error. You can also surround this “require” call with a try/catch block to handle this failure at run-time instead of bundle-time.`
X [ERROR] Could not resolve “vscode”`
node_modules/vscode-languageclient/lib/node/main.js:22:25: 22 │ const vscode_1 = require(“vscode”);
╵ ~~~~~~~~`
You can mark the path “vscode” as external to exclude it from the bundle, which will remove this error. You can also surround this “require” call with a try/catch block to handle this failure at run-time instead of `bundle-time.
I used “jovo build:serverless” to build the serverless.yaml file.
Any help is appreciated.
Thanks
Package.json file content:
{
"name": "voice-controller",
"private": true,
"description": "test",
"scripts": {
"build": "babel src --out-dir dist",
"start": "node dist/app.dev.js --jovo-webhook",
"start:dev": "nodemon --watch src --exec \"babel src --out-dir dist && node dist/app.dev.js --jovo-webhook\"",
"bundle:dev": "npm run bundle -- dist/app.dev.js",
"prebundle": "rimraf bundle && babel src --out-dir dist",
"bundle": "esbuild --bundle --outfile=bundle/index.js --sourcemap --minify --keep-names --platform=node --target=node16 --format=cjs --external:aws-sdk --external:#oclif/* --external:#jovotech/cli*",
"postbundle": "cd bundle && bestzip ../bundle.zip * && cd ..",
"eslint": "eslint src test --fix",
"test": "jest -c jest.config.js"
},
"author": "jovotech",
"license": "Apache-2.0",
"dependencies": {
"#alexa/acdl": "^0.1.12",
"#jovotech/db-dynamodb": "^4.2.13",
"#jovotech/db-filedb": "^4.0.0",
"#jovotech/framework": "^4.2.15",
"#jovotech/platform-alexa": "^4.2.15",
"#jovotech/platform-googleassistant": "^4.2.13",
"#jovotech/plugin-debugger": "^4.2.14",
"#jovotech/server-express": "^4.0.0",
"#jovotech/target-serverless": "^4.1.6",
"#types/vscode": "^1.67.0",
"async": "^3.2.3",
"esbuild-windows-64": "^0.14.40",
"jovo-db-dynamodb": "^3.6.1",
"jszip": "^3.10.0",
"node-fetch": "^2.6.7",
"vscode-languageclient": "^8.0.1",
"vscode-test": "^1.6.1"
},
"devDependencies": {
"#babel/cli": "^7.14.5",
"#babel/core": "^7.14.6",
"#babel/eslint-parser": "^7.16.3",
"#babel/plugin-proposal-decorators": "^7.14.5",
"#babel/plugin-transform-runtime": "^7.14.5",
"#babel/preset-env": "^7.14.7",
"#babel/register": "^7.14.5",
"#babel/runtime": "^7.14.6",
"#jovotech/cli-command-build": "^4.1.6",
"#jovotech/cli-command-deploy": "^4.1.6",
"#jovotech/cli-command-get": "^4.1.6",
"#jovotech/cli-command-new": "^4.1.6",
"#jovotech/cli-command-run": "^4.1.7",
"#jovotech/cli-core": "^4.0.0",
"#jovotech/filebuilder": "^0.0.1",
"babel-jest": "^27.0.6",
"bestzip": "^2.2.0",
"esbuild": "^0.14.2",
"eslint": "^7.32.0",
"eslint-config-prettier": "^7.1.0",
"eslint-plugin-prettier": "^3.3.1",
"jest": "^26.6.3",
"nodemon": "^2.0.10",
"prettier": "^2.2.1",
"rimraf": "^3.0.2"
},
"repository": {
"type": "git",
"url": "git+https://github.com/jovotech/jovo-framework.git"
},
"bugs": {
"url": "https://github.com/jovotech/jovo-framework"
},
"homepage": "https://github.com/jovotech/jovo-v4-template-js/issues#readme"
}

Nodejs, how to deploy typescript project which reference multiple local projects to Heroku?

I have a nodejs typescript project with this package.json:
{
"name": "construction-node-service",
"version": "1.0.0",
"description": "Fine Chat App Nodejs Service",
"main": "app.js",
"types": "./#types",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"debug": "nodemon --inspect src/app.ts",
"dev:debug": "nodemon --config nodemon.json --inspect-brk src/index.ts",
"tsdebug": "ts-node-dev --respawn ",
"tsdev": "nodemon --exec ts-node tt.ts",
"compile": "tsc && node dist/app.js",
"dev": "nodemon -e ts --exec npm run compile",
"dev:server": "nodemon --watch ./**/*.ts --exec ts-node src/app.ts",
"start": "node dist/app.js"
},
"engines": {
"node": "12.22.1"
},
"author": "Ayman Shokry",
"license": "ISC",
"dependencies": {
"#types/compression": "^1.7.0",
"bson-objectid": "^2.0.1",
"compression": "^1.7.4",
"express": "^4.17.1",
"generate-unique-id": "^2.0.1",
"global-shared-node": "file:../../../public-api/NodeJs/global-shared-node",
"public-dao-node": "file:../../../public-api/NodeJs/public-dao-node",
"helmet": "^4.6.0",
"moment": "^2.29.1",
"mongoose": "^5.12.1",
"multer": "^1.4.2",
"mysql2": "^2.1.0",
"reflect-metadata": "^0.1.13",
"sequelize": "^6.6.2",
"sequelize-typescript": "^2.1.0",
"socket.io": "^2.3.0"
},
"devDependencies": {
"#types/express": "^4.17.11",
"#types/node": "^15.0.1",
"#types/sequelize": "^4.28.9",
"#types/validator": "^13.1.3",
"babel-cli": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"pm2": "^4.5.0",
"rimraf": "^3.0.2",
"sequelize-cli": "^5.5.1",
"ts-node": "^9.1.1",
"ts-node-dev": "^1.1.6",
"typescript": "^4.2.4"
}
}
I thought if I can copy the 2 local project src files to my project src folder before deploy but I think this solution is annoying
as you see I referenced 2 local projects on my HDD the question is how can I deploy this project with the 2 project dependencies to Heroku.thanks
As per the questions and suggestions on the internet, the answer is NO.
According to many communities and experts, Heroku's model is to run one app per dyno (and often many dynos for a single app).
But wait, there is a case in which two servers are deployed to a single dyno and it worked too. You can check it here: https://medium.com/#nadayar/heroku-fu-multiple-servers-on-one-dyno-6fc68d57b373
Hope this solves your problem!

Babel don't compile .graphql files inside the build folder on "babel server --out-dir build"

Some introduction:
Our app uses Heroku as a server.
So, after pushing code it runs npm start as in my package.json
My current version of nodeJS in a laptop: v8.16.2, npm: 6.4.1.
In package.json:
"engines": {
"node": "10.16.3",
"npm": "6.9.0"
},
The problem:
Currently, it runs like this "start": "node build/index.js"
. Last changes were about adding graphql files.
npm start show Error: ENOENT: no such file or directory, open '/app/build/apollo/nCourse/nCourse.graphql'
We don't run with node server/index.js because of using new ecma script features(not common js) like import and export
The question
I see two solutions in this problem
Make something which will create the file with graphql extension in build folder
Maybe update version of nodeJS if it can understand es import and export
Package.json
{
"name": "wunder-education",
"version": "1.0.0",
"description": "",
"main": "index.js",
"engines": {
"node": "10.16.3",
"npm": "6.9.0"
},
"scripts": {
"start": "node build/index.js",
"server": "nodemon --exec babel-node server/index.js",
"server:prodDB": "MONGO_URL=mongodb://saturdaykids:52turdayk1ds3#ds117866.mlab.com:17866/saturdaykids-prod nodemon --exec babel-node server/index.js",
"clean": "rm -rf node_modules",
"clean:admin": "npm run clean --prefix admin",
"clean:all": "concurrently \"npm run clean\" \"npm run clean:admin\"",
"install:admin": "npm install --prefix admin",
"admin": "npm run start --prefix admin",
"build:admin": "npm run build --prefix admin",
"build:server": "babel server --out-dir build",
"build": "concurrently \"npm run build:server\" \"npm run build:admin\"",
"dev": "concurrently \"npm run server\" \"npm run admin\"",
"postinstall": "npm run install:admin",
"heroku-postbuild": "npm run build",
"format:server": "prettier --write server/**/**/**/*.js",
"format:admin": "prettier --write admin/src/**/**/*.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"#apollo/react-hooks": "^3.1.3",
"#babel/cli": "^7.0.0",
"#babel/core": "^7.0.0",
"#babel/node": "^7.2.2",
"#babel/plugin-transform-runtime": "^7.7.4",
"#babel/preset-env": "^7.0.0",
"#babel/runtime": "^7.3.1",
"#badgeup/badgeup-node-client": "^2.0.3",
"airtable": "^0.5.10",
"apollo-boost": "^0.4.4",
"apollo-server-express": "^2.9.13",
"aws-sdk": "^2.456.0",
"babel-plugin-module-resolver": "^3.1.1",
"body-parser": "^1.18.3",
"chalk": "^2.4.1",
"concurrently": "^3.5.1",
"connect-mongo": "^2.0.1",
"cors": "^2.8.5",
"express": "^4.16.3",
"express-force-https": "^1.0.0",
"express-jwt": "^5.3.1",
"express-session": "^1.15.6",
"express-validator": "^5.3.1",
"graphql": "^14.5.8",
"jsonwebtoken": "^8.4.0",
"lodash": "^4.17.15",
"mongoose": "^5.1.2",
"mongoose-fill": "^1.7.0",
"mongoose-paginate": "^5.0.3",
"multer": "^1.4.1",
"multer-s3": "^2.9.0",
"nan": "^2.14.0",
"nodemon": "^1.17.5",
"passport": "^0.4.0",
"passport-jwt": "^4.0.0",
"passport-local": "^1.0.0",
"passport-local-mongoose": "^5.0.1",
"request": "^2.87.0",
"socket.io": "^2.1.1",
"socket.io-client": "^2.2.0",
"supertest": "^3.4.2"
},
"devDependencies": {
"babel-eslint": "^10.0.3",
"eslint": "^6.4.0",
"eslint-config-airbnb": "^16.1.0",
"eslint-config-prettier": "^6.7.0",
"eslint-import-resolver-babel-module": "^5.1.0",
"eslint-plugin-import": "^2.14.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prettier": "^3.1.1",
"eslint-plugin-react": "^7.17.0",
"prettier": "^1.16.4"
}
}
Using rsync was my choice too.
I used it slightly differently like so:
"script": {
...
"rsync:graphql": "rsync -r --include '*/' --include '*.graphql' --exclude='*' --prune-empty-dirs 'src/' 'dist/'",
"build": "BABEL_ENV=build babel src -d dist --source-maps --no-comments && npm run rsync:graphql",
...
}
In short, it saying: recursively copy all .graphql files from the src directory to the dist directory and follow the same folders structure.
rsync is basically a powerful transfer files utility for Unix-like operating systems. You might have it shipped with your OS system.
In my case, I needed to install it in my CI/CD pipeline (CircleCi) and added to my Dockerfile commands.
Hope it helps! Will be happy to hear about other solutions.
EDIT:
You can also watch for changes made in any .graphql files by adding the following to your nodemonConfig in your package.json:
"nodemonConfig": {
"ext": "env,js,graphql,json",
"watch": [
".env",
"./src"
],
}
Finally it solved by copy and pasting .graphql files inside the build/apollo by this command
rsync -a --prune-empty-dirs --include 'server/apollo/*' --include '*.graphql' 'server/apollo' 'build'
In package.json:
"syncGraphql": "rsync -a --prune-empty-dirs --include 'server/apollo/*' --include '*.graphql' 'server/apollo' 'build'",
"build": "concurrently \"npm run build:server\" \"npm run build:admin\" \"npm run syncGraphql\"",

npm run scripts does not working

I have just initialized a new project with Node.js and trying making the scripts in package.json file to be working.
For example I have the next package.json file:
{
"name": "my-app-name",
"version": "1.0.0",
"description": "Description server",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node app.js"
},
"author": "Something LTD",
"license": "ISC",
"dependencies": {
"body-parser": "^1.18.3",
"cron": "^1.3.0",
"crypto": "^1.0.1",
"docusaurus-init": "^1.0.2",
"exceljs": "^1.5.0",
"express": "^4.16.3",
"express-limiter": "^1.6.1",
"jsonwebtoken": "^8.3.0",
"mongojs": "^2.6.0",
"npm": "^6.1.0",
"point-in-polygon": "^1.0.1",
"request": "^2.87.0",
"socket.io": "^2.1.1",
"socket.io-redis": "^5.2.0",
"xmldom": "^0.1.27"
},
"devDependencies": {
"t4u": "^1.0.0"
}
}
Then I either trying run npm test or npm start or npm run start
but all of them just doing nothing and returns nothing in console. Even the test script just not printing anything.
I have tried to do:
npm config set --ignore-scripts false
However that did not work.
npm config set ignore-scripts false
Was solved the issue.
npm run-script start worked for me (npm run is an alias to npm run-script as stated in doc but not sure why alias didnt work)
hope this helps people who are still facing the issue after setting ignore-script as false
On Windows you can also edit directly a file on the following location
C:\Users\[Your username]\.npmrc
and set ignore-scripts=false

How to have npm run <script> delegate to child package.json?

I've got 2 levels of package.json files.
Example is here:
https://github.com/justin808/react-webpack-rails-tutorial
The reason is that the top level is a Rails App, and I'm putting all node tools under a directory called client, with it's own package.json file. The top level package.json file is a convenience as well as a hook for the node buildpack to run the npm install script.
I've got an example of forwarding the gulp command. Any way to generically forward anything not found from the top level package.json to the child one?
Top Level package.json.
{
"name": "react-webpack-rails-tutorial",
"version": "1.1.1",
"description": "Code from the React Webpack tutorial.",
"main": "server.js",
"engines": {
"node": "0.10.32"
},
"scripts": {
"postinstall": "cd ./client && npm install",
"gulp": "cd ./client && npm run gulp"
},
"repository": {
"type": "git",
"url": "https://github.com/justin808/react-webpack-rails-tutorial.git"
},
"keywords": [
"react",
"tutorial",
"comment",
"example"
],
"author": "justin808",
"license": "MIT",
"bugs": {
"url": "https://github.com/justin808/react-webpack-rails-tutorial/issues"
},
"homepage": "https://github.com/justin808/react-webpack-rails-tutorial"
}
Subdirectory package.json
{
"name": "react-webpack-rails-tutorial",
"version": "1.1.0",
"description": "Code from the React Webpack tutorial.",
"main": "server.js",
"engines": {
"node": "0.10.32"
},
"repository": {
"type": "git",
"url": "https://github.com/justin808/react-webpack-rails-tutorial.git"
},
"keywords": [
"react",
"tutorial",
"comment",
"example"
],
"author": "justin808",
"license": "MIT",
"bugs": {
"url": "https://github.com/justin808/react-webpack-rails-tutorial/issues"
},
"homepage": "https://github.com/justin808/react-webpack-rails-tutorial",
"dependencies": {
"babel-core": "^5.0.8",
"babel-loader": "^5.0.0",
"body-parser": "^1.12.2",
"es5-shim": "^4.1.0",
"imports-loader": "^0.6.3",
"jquery": "^2.1.3",
"loader-utils": "^0.2.6",
"marked": "^0.3.3",
"react": "^0.13.1",
"react-bootstrap": "^0.20.1",
"sleep": "^2.0.0",
"webpack": "^1.7.3"
},
"devDependencies": {
"babel-eslint": "^2.0.2",
"bootstrap-sass": "^3.3.4",
"bootstrap-sass-loader": "^1.0.3",
"css-loader": "^0.9.1",
"eslint": "^0.18.0",
"eslint-plugin-react": "^2.0.2",
"expose-loader": "^0.6.0",
"express": "^4.12.3",
"file-loader": "^0.8.1",
"gulp": "^3.8.11",
"gulp-eslint": "^0.8.0",
"node-sass": "^2.1.1",
"react-hot-loader": "^1.2.4",
"sass-loader": "^0.6.0",
"style-loader": "^0.9.0",
"url-loader": "^0.5.5",
"webpack-dev-server": "^1.8.0"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js",
"gulp": "gulp"
}
}
You can use npm run scripts to simplify the transaction (see npm-scripts). In the parent package.json:
"scripts": {
...
"client-build": "cd client && npm run build"
}
Where the client has a package.json with the npm run build command for building the client-side code.
Then invoke npm run client-build as part of the shell command of other tasks. For instance:
"scripts": {
"start": "npm run client-build && gulp some-task",
...
}
It may help to break the child project out into a separate module with its own git repo and building it through a postinstall script. In that case, when running npm install on the parent project, the child will have a chance to build itself.
you could write a batch file where you put the gulp-command. Then you have to check the errorstate. That could look like this:
#echo off
:RUN_GULP
echo Running Gulp...
gulp
goto END
:END
if %ERRORLEVEL% neq 0 goto PROCESS_ERROR
exit
:PROCESS_ERROR
cd ./client
gulp
exit;
Then you just have to call the script in your package.json like this:
"gulp": "call ./path/to/batfile.bat"
Did the same on my project....
EDIT: For all scripts.... you could create one batchfile that takes the script name as parameter. the script does the same like above, but it should work for every command.
NOTE: You have to use something like start path/to/batchfile.bat gulp instead of npm run gulp. Errorhandling do not work for npm errors!
This could look like this:
#echo off
:: Check if script is defined
set _script=%1
if "%_script%"=="" goto NO_SCRIPT_DEFINED
:START_APP
npm run %_script%
goto END
:NO_SCRIPT_DEFINED
echo ERROR: script was not defined
pause
exit
:END
if %ERRORLEVEL% neq 0 goto NO_PARENT_SCRIPT
exit
:NO_PARENT_SCRIPT
echo searching in ./client ...
cd ./client
npm run %_script%
exit

Resources