Perhaps I'm missing something, since I've never encountered this before, but I'm trying to run a Node/Express/Babel setup with nodemon, and every time there is a crash (almost), nodemon leaves the port in use, so I have to manually kill the process. I'm using Node 11.15.0 and MacOS 10.13.6 and the error I get is
events.js:170
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE: address already in use :::4321
at Server.setupListenHandle [as _listen2] (net.js:1259:14)
at listenInCluster (net.js:1307:12)
at Server.listen (net.js:1395:7)
at listen (/Users/robertanthony/Documents/Projects/sandbox/axa/src/index.js:27:10)
at $initialConnection.$initialConnection.then (/Users/thisuser/Documents/Projects/sandbox/axa/node_modules/mongoose/lib/connection.js:723:13)
at processTicksAndRejections (internal/process/task_queues.js:86:5)
Emitted 'error' event at:
at emitErrorNT (net.js:1286:8)
at processTicksAndRejections (internal/process/task_queues.js:81:17)
[nodemon] app crashed - waiting for file changes before starting...
My package.json is
{
"scripts": {
"start": "nodemon --exec babel-node src/index.js",
"lint": "eslint \"src/**/*.{js}\" --quiet",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"dotenv": "^8.1.0",
"express": "^4.17.1",
"express-async-handler": "^1.1.4",
"express-jwt": "^5.3.1",
"express-jwt-permissions": "^1.3.1",
"express-session": "^1.16.2",
"jsonwebtoken": "^8.5.1",
"mongodb": "^3.3.2",
"mongoose": "^5.7.1",
"winston": "^3.2.1"
},
"devDependencies": {
"#babel/core": "^7.6.0",
"#babel/node": "^7.6.1",
"#babel/preset-env": "^7.5.5",
"eslint": "^6.2.2",
"eslint-config-prettier": "^6.1.0",
"nodemon": "^1.19.2",
"prettier": "^1.18.2"
}
}
Perhaps it's something I'm doing wrong? Any help much appreciated -- If it's not obvious what the solution is, is there any way to run babel without nodemon? I tried 'node --exec' but that didn't work…
Related
I am having lots of trouble resolving this bug. I wrote a prisma nodejs application with react frontend and am ready to deploy. The app is working perfectly on my ubuntu system but everytime i try to run
sudo docker-compose up --build
I run into the same error
app/node_modules/.prisma/client/index.js:3
throw new Error(
^
Error: #prisma/client did not initialize yet. Please run "prisma generate" and try to import it again.
In case this error is unexpected for you, please report it in https://github.com/prisma/prisma/issues
at new PrismaClient (/app/node_modules/.prisma/client/index.js:3:11)
at Object.<anonymous> (/app/build/decks.js:10:16)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
at Module.load (node:internal/modules/cjs/loader:1033:32)
at Function.Module._load (node:internal/modules/cjs/loader:868:12)
at Module.require (node:internal/modules/cjs/loader:1057:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (/app/build/game.js:41:17)
at Module._compile (node:internal/modules/cjs/loader:1155:14)
/app/node_modules/.prisma/client/index.js:3
throw new Error(
no matter what i try
this is my Dockerfile for my node application:
FROM node:16
WORKDIR /app
COPY package*.json ./
COPY prisma ./prisma/
COPY . .
RUN npm install
EXPOSE 8000
CMD [ "node", "build/server.js" ]
my .env
MYSQL_HOST="localhost"
MYSQL_USER="game"
MYSQL_NAME="mygame"
MYSQL_PASS="mypassword"
MYSQL_ROOT_PASSWORD=mynewpassword
DB_URL="mysql://game:mypassword#localhost:3307/mygame"
DB_LOCAL_PORT=3307
DB_DOCKER_PORT=3308
NODE_LOCAL_PORT=8000
NODE_DOCKER_PORT=8000
and my package.json
{
"name": "nodejsin30min",
"version": "1.0.0",
"description": "",
"main": "./src/server.ts",
"scripts": {
"generate": "npx prisma generate",
"deploy": "npx prisma migrate deploy",
"devStart": "nodemon ./src/server.ts",
"test": "jest",
"build": "tsc -p",
"postinstall": "prisma generate"
},
"prisma": {
"schema": "./prisma/schema.prisma"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#prisma/client": "^4.6.1",
"#socket.io/admin-ui": "^0.2.0",
"#types/jest": "^28.1.7",
"#types/mocha": "^9.1.1",
"bcrypt": "^5.1.0",
"bcrypt-helper": "^0.2.1",
"body-parser": "^1.20.1",
"chroma": "^0.0.1",
"circular-json": "^0.5.9",
"cors": "^2.8.5",
"dotenv": "^16.0.3",
"express": "^4.17.1",
"express-jwt": "^7.7.7",
"express-oauth2-jwt-bearer": "^1.2.0",
"express-openid-connect": "^2.9.0",
"express-rate-limit": "^6.7.0",
"flatted": "^3.2.5",
"jwks-rsa": "^2.1.5",
"knex": "^2.3.0",
"mysql": "^2.18.1",
"mysql2": "^2.3.3",
"prisma": "^4.6.1",
"socket.io": "^4.4.0",
"socket.io-client": "^4.4.0",
"sqlite3": "^5.0.9",
"typesync": "^0.9.2",
"underscore": "^1.13.1",
"webpack": "^5.74.0"
},
"devDependencies": {
"#prisma/client": "^4.6.1",
"#types/express": "^4.17.13",
"#types/express-jwt": "^7.4.2",
"#types/jest": "^28.1.7",
"#types/mocha": "^9.1.1",
"#types/mysql": "^2.15.21",
"#types/node": "^18.7.7",
"#types/underscore": "^1.11.4",
"jest": "^27.4.3",
"nodemon": "^2.0.15",
"prisma": "^4.6.1",
"ts-node": "^10.9.1",
"typescript": "^4.4.3"
}
}
As you can see I already tried implementing a posinstall script with no luck. I have already tried shifting around multiple prisma commands (migrate dev, migrate deploy, generate) into every possible position of my Dockerfile with no luck - always the same error. On my device I NEVER had to manually generate a client and before i implemented prisma the application could be built just fine. I have no more ideas what to look for.
any help is appreciated.
Furthermore i habe already tried leaving out enironment variables and instead hardcoding the values, which did not work either
I also tried running RUN npm i -g prisma befor a prisma generate in my Dockerfile
I inherited an application has has begun to get large and I am receiving the error message CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory. Based on my research I need to set the node argument max_old_space_size.
I am currently running Node 7.8.0 so it does not appear I can use the environment variable NODE_OPTIONS, I have tried to set this with no luck. I have pasted my existing package.json file below but I cannot figured out where in the scripts section I can place the argument --max_old_space_size=2048
The node process typically crashes with the above error when the memory gets around 1.6 GB
{
"scripts": {
"lint": "tslint --exclude=node_modules/** **/*.ts",
"generate:client": "ts-node ./swagger/generate-client.ts --baseApiUrl=http://localhost:5003",
"generate:client:prod": "ts-node ./swagger/generate-client.ts --baseApiUrl=%API_URL%",
"start": "npm run clean:dist && npm run generate:client && webpack -w",
"clean:dist": "rimraf ./wwwroot/*",
"build": "npm run clean:dist && npm run generate:client:prod && webpack -p"
},
"dependencies": {
"#types/googlemaps": "^3.26.1",
"#types/handlebars": "^4.0.31",
"#types/node": "^7.0.5",
"#types/react": "^15.0.34",
"#types/react-dom": "^15.5.1",
"#types/react-router": "^3.0.3",
"#types/superagent": "^2.0.36",
"#types/yargs": "^6.6.0",
"assets-webpack-plugin": "^3.5.1",
"css-loader": "^0.26.1",
"extract-text-webpack-plugin": "2.1.2",
"file-loader": "^0.10.0",
"google-map-react": "^0.22.3",
"handlebars": "^4.0.6",
"mobx": "^3.1.0",
"mobx-react": "^4.1.0",
"moment": "^2.17.1",
"node-sass": "^4.5.0",
"react": "^15.6.1",
"react-dom": "^15.6.1",
"react-resize-observer": "^0.1.0",
"react-router": "^3.0.2",
"rimraf": "^2.6.1",
"sass-loader": "^6.0.1",
"style-loader": "^0.13.1",
"superagent": "^3.4.4",
"ts-loader": "^2.2.2",
"ts-node": "^3.1.0",
"tslint": "^4.4.2",
"tslint-loader": "^3.5.3",
"tslint-react": "^3.0.0",
"typescript": "^2.4.1",
"url-loader": "^0.5.7",
"webpack": "^3.1.0",
"webpack-md5-hash": "^0.0.5",
"yargs": "^6.6.0"
}
}
Update 8/27/2020:
I have attempted to use the proposed solution of:
"scripts": {
"high-memory": "node --max_old_space_size=2048 ./node_modules/.bin/ts-node",
"generate:client": "npm run high-memory -- ./swagger/generate-client.ts --baseApiUrl=http://localhost:5003",
"generate:client:prod": "npm run high-memory -- ./swagger/generate-client.ts --baseApiUrl=%API_URL%",
}
Receiving the following error when running npm start:
C:\Projects\Twiddy\TwiddyOps\Web\node_modules\.bin\ts-node:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at createScript (vm.js:53:10)
at Object.runInThisContext (vm.js:95:10)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:423:7)
at startup (bootstrap_node.js:147:9)
Tell the author that this fails on your system:
npm ERR! node --max_old_space_size=2048 ./node_modules/.bin/ts-node
"./swagger/generate-client.ts" "--baseApiUrl=http://localhost:5003"
That's how I use it:
"scripts": {
"high-memory": "node --max_old_space_size=2048 ./node_modules/.bin/ts-node",
"generate:client": "npm run high-memory -- ./swagger/generate-client.ts --baseApiUrl=http://localhost:5003",
"generate:client:prod": "npm run high-memory -- ./swagger/generate-client.ts --baseApiUrl=%API_URL%",
}
I have installed tinymce in my EmberJS application. When I run npm start or even npm run build, I get an error like so:
[Package /assets/vendor.js]/home/ikirkpat/Projects/proj_name/frontend/node_modules/typescript/lib/typescript.js:98681
throw e;
Error: Debug Failure.
at Object.assertDefined (/home/ikirkpat/Projects/proj_name/frontend/node_modules/typescript/lib/typescript.js:2227:24)
at /home/ikirkpat/Projects/proj_name/frontend/node_modules/typescript/lib/typescript.js:39474:34
at Object.filter (/home/ikirkpat/Projects/proj_name/frontend/node_modules/typescript/lib/typescript.js:513:31)
at serializeAsClass (/home/ikirkpat/Projects/proj_name/frontend/node_modules/typescript/lib/typescript.js:39472:48)
at serializeSymbolWorker (/home/ikirkpat/Projects/proj_name/frontend/node_modules/typescript/lib/typescript.js:39203:29)
at serializeSymbol (/home/ikirkpat/Projects/proj_name/frontend/node_modules/typescript/lib/typescript.js:39144:38)
at /home/ikirkpat/Projects/proj_name/frontend/node_modules/typescript/lib/typescript.js:39119:25
at Map.forEach (<anonymous>)
at visitSymbolTable (/home/ikirkpat/Projects/proj_name/frontend/node_modules/typescript/lib/typescript.js:39118:33)
at symbolTableToDeclarationStatements (/home/ikirkpat/Projects/proj_name/frontend/node_modules/typescript/lib/typescript.js:38989:17)
⠧ building... [SassCompiler](node:14526) UnhandledPromiseRejectionWarning: Error: Debug Failure.
at CommandCoordinator.dispatchResponse (/home/ikirkpat/Projects/proj_name/frontend/node_modules/stagehand/lib/command-coordinator.js:54:69)
at CommandCoordinator.<anonymous> (/home/ikirkpat/Projects/proj_name/frontend/node_modules/stagehand/lib/command-coordinator.js:43:29)
at Generator.next (<anonymous>)
at /home/ikirkpat/Projects/proj_name/frontend/node_modules/stagehand/lib/command-coordinator.js:7:71
at new Promise (<anonymous>)
at __awaiter (/home/ikirkpat/Projects/proj_name/frontend/node_modules/stagehand/lib/command-coordinator.js:3:12)
at CommandCoordinator.messageReceived (/home/ikirkpat/Projects/proj_name/frontend/node_modules/stagehand/lib/command-coordinator.js:40:16)
at ChildProcess.emit (events.js:311:20)
at emit (internal/child_process.js:876:12)
at processTicksAndRejections (internal/process/task_queues.js:85:21)
(node:14526) UnhandledPromiseRejectionWarning: Error: Debug Failure.
at CommandCoordinator.dispatchResponse (/home/ikirkpat/Projects/proj_name/frontend/node_modules/stagehand/lib/command-coordinator.js:54:69)
at CommandCoordinator.<anonymous> (/home/ikirkpat/Projects/proj_name/frontend/node_modules/stagehand/lib/command-coordinator.js:43:29)
at Generator.next (<anonymous>)
at /home/ikirkpat/Projects/proj_name/frontend/node_modules/stagehand/lib/command-coordinator.js:7:71
at new Promise (<anonymous>)
at __awaiter (/home/ikirkpat/Projects/proj_name/frontend/node_modules/stagehand/lib/command-coordinator.js:3:12)
at CommandCoordinator.messageReceived (/home/ikirkpat/Projects/proj_name/frontend/node_modules/stagehand/lib/command-coordinator.js:40:16)
at ChildProcess.emit (events.js:311:20)
at emit (internal/child_process.js:876:12)
at processTicksAndRejections (internal/process/task_queues.js:85:21)
(node:14526) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 15)
For background, this was building perfectly before. Then I merged my teams master branch into my feature branch to fix merge conflicts and now it won't build.
So here is my package.json:
{
"name": "...",
"version": "0.0.0",
"private": true,
"description": "...",
"repository": "",
"license": "MIT",
"author": "",
"directories": {
"doc": "doc",
"test": "tests"
},
"scripts": {
"build": "ember build",
"codegen": "graphql-codegen",
"lint:hbs": "ember-template-lint .",
"lint:js": "eslint .",
"start": "ember serve --ssl --secure-proxy false --proxy https://localhost:5001 --environment local",
"test": "ember test"
},
"devDependencies": {
"#ember/edition-utils": "^1.1.1",
"#ember/jquery": "^1.1.0",
"#ember/optional-features": "^1.1.0",
"#glimmer/component": "^1.0.0",
"#types/ember": "^3.1.1",
"#types/ember-qunit": "^3.4.7",
"#types/ember__test-helpers": "^0.7.9",
"#types/qunit": "^2.9.0",
"#types/rsvp": "^4.0.3",
"apollo-link-error": "^1.1.12",
"babel-eslint": "^10.0.2",
"broccoli-asset-rev": "^3.0.0",
"ember-animated": "^0.9.0",
"ember-apollo-client": "2.0.0",
"ember-auto-import": "^1.5.3",
"ember-cli": "~3.15.1",
"ember-cli-app-version": "^3.2.0",
"ember-cli-babel": "^7.13.0",
"ember-cli-dependency-checker": "^3.2.0",
"ember-cli-deploy": "^1.0.2",
"ember-cli-deploy-build": "^2.0.0",
"ember-cli-deploy-s3": "^1.4.0",
"ember-cli-htmlbars": "^4.2.0",
"ember-cli-inject-live-reload": "^2.0.1",
"ember-cli-sass": "^10.0.1",
"ember-cli-sri": "^2.1.1",
"ember-cli-typescript": "^3.1.1",
"ember-cli-typescript-blueprints": "^3.0.0",
"ember-cli-uglify": "^3.0.0",
"ember-cli-update": "^0.49.6",
"ember-css-modules": "^1.3.0-beta.1",
"ember-css-modules-sass": "^1.0.1",
"ember-drag-drop": "atomicobject/ember-drag-drop#feature/horizontal-sorting-improvements",
"ember-export-application-global": "^2.0.1",
"ember-fetch": "^7.0.0",
"ember-intl": "^4.2.2",
"ember-load-initializers": "^2.1.1",
"ember-maybe-import-regenerator": "^0.1.6",
"ember-paper": "^1.0.0-beta.26",
"ember-qunit": "^4.6.0",
"ember-resolver": "^7.0.0",
"ember-source": "https://s3.amazonaws.com/builds.emberjs.com/beta/shas/49ae818907447d9c469d68b297060f00728ffb5a.tgz",
"ember-template-lint": "^1.5.0",
"ember-test-selectors": "^2.1.0",
"ember-tooltips": "^3.4.2",
"ember-welcome-page": "^4.0.0",
"ember-wormhole": "^0.5.5",
"eslint": "^6.1.0",
"eslint-plugin-ember": "^7.7.1",
"eslint-plugin-node": "^10.0.0",
"graphql": "^14.5.8",
"liquid-fire": "^0.31.0",
"loader.js": "^4.7.0",
"qunit-dom": "^0.9.2",
"sass": "^1.23.3",
"typescript": "^3.7.2"
},
"engines": {
"node": "8.* || >= 10.*"
},
"ember": {
"edition": "octane"
},
"dependencies": {
"#ember/render-modifiers": "^1.0.2",
"#glimmer/tracking": "^0.14.0-alpha.1",
"#graphql-codegen/cli": "^1.9.1",
"#graphql-codegen/near-operation-file-preset": "^1.9.1",
"#graphql-codegen/typescript": "^1.9.1",
"#graphql-codegen/typescript-compatibility": "^1.9.1",
"#graphql-codegen/typescript-operations": "^1.9.1",
"#simple-dom/interface": "^1.4.0",
"#types/faker": "^4.1.8",
"#types/lodash-es": "^4.17.3",
"#types/tinymce": "^4.5.24",
"apollo-cache-inmemory": "^1.6.3",
"apollo-link": "^1.2.13",
"apollo-link-batch-http": "^1.2.13",
"bufferutil": "^4.0.1",
"cldr-core": "^36.0.0",
"ember-click-outside": "^1.3.0",
"ember-concurrency-decorators": "^1.0.0",
"ember-file-upload": "^2.7.1",
"ember-hacky-set-value": "0.0.1",
"es6-promise": "^4.2.8",
"faker": "^4.1.0",
"isomorphic-fetch": "^2.2.1",
"lodash-es": "^4.17.15",
"moment": "^2.24.0",
"tinymce": "^5.2.1"
}
}
It was builing until the ember-hacky-set-value package was introduced so I wonder if that's the problem. But that seems like a completely unrelated change that shouldn't have effected tinymce. So maybe it's something else?
You just need to change line "typescript": "^3.7.2" -> "typescript": "~3.7.2"
Somehow your typescript got updated to 3.8, which has this issue: https://github.com/typed-ember/ember-cli-typescript/issues/1103
I have too many tables in my SQL server database and my application uses sequelize ORM of node.js.
I find out that there is a way to scaffold my database models and it is sequelize-auto command.
So I created a command and run it. but it throws an error!
here is my sequelize-auto command:
sequelize-auto -h my server_ip_address -d database_name -u username -x mypassword --dialect mssql -c ./api/config/onlinestore.json -o ./api/models/newScafolded
but when I run this command it throws this error:
C:\Users\AMoha\AppData\Roaming\npm\node_modules\sequelize-auto\node_modules\sequelize\lib\dialects\mssql\connection-manager.js:21
throw new Error('Please install tedious package manually');
^
Error: Please install tedious package manually
at new ConnectionManager (C:\Users\AMoha\AppData\Roaming\npm\node_modules\sequelize-auto\node_modules\sequelize\lib\dialects\mssql\connection-manager.js:21:13)
at new MssqlDialect (C:\Users\AMoha\AppData\Roaming\npm\node_modules\sequelize-auto\node_modules\sequelize\lib\dialects\mssql\index.js:12:28)
at new Sequelize (C:\Users\AMoha\AppData\Roaming\npm\node_modules\sequelize-auto\node_modules\sequelize\lib\sequelize.js:233:18)
at new AutoSequelize (C:\Users\AMoha\AppData\Roaming\npm\node_modules\sequelize-auto\lib\index.js:19:22)
at Object.<anonymous> (C:\Users\AMoha\AppData\Roaming\npm\node_modules\sequelize-auto\bin\sequelize-auto:90:12)
at Module._compile (internal/modules/cjs/loader.js:945:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:962:10)
at Module.load (internal/modules/cjs/loader.js:798:32)
at Function.Module._load (internal/modules/cjs/loader.js:711:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:1014:10)
at internal/main/run_main_module.js:17:11
I installed and used tedious package.
here is my package.json content:
{
"name": "onlinestore",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "babel-watch ./bin/www",
"start": "node ./bin/www"
},
"dependencies": {
"body-parser": "^1.19.0",
"braces": "^3.0.2",
"constantinople": "^4.0.1",
"cookie-parser": "~1.3.3",
"cors": "^2.8.5",
"custom-env": "^1.0.0",
"debug": "^4.1.0",
"express": "^4.16.4",
"express-jwt": "^3.4.0",
"jade": "~1.9.1",
"jsonwebtoken": "^5.7.0",
"lodash": "^4.17.15",
"mongoose": "^5.8.7",
"morgan": "^1.9.1",
"passport": "^0.2.2",
"passport-local": "^1.0.0",
"sequelize": "^5.21.5",
"serve-favicon": "^2.5.0",
"tedious": "^6.7.0",
"uglify-js": "^3.4.9"
},
"devDependencies": {
"#babel/cli": "^7.4.4",
"#babel/core": "^7.4.4",
"#babel/preset-env": "^7.4.4",
"babel-watch": "^7.0.0",
"gulp": "^4.0.0",
"gulp-concat": "^2.6.0",
"gulp-ng-annotate": "^1.1.0",
"gulp-ng-html2js": "^0.2.3",
"gulp-sourcemaps": "^1.5.2",
"gulp-uglify": "^1.2.0",
"gulp-watch": "^5.0.1"
}
}
What's your idea?
Finally I found the solution.
I should install tedious and mssql package in the same path.
I run below command and my problem solved:
npm install -g mssql tedious
I searched again and finally I found overall solution.
A GUI Desktop App for export sequelize models from database automatically. click here to see what it will do. I used it and it worked for me.
I would appreciate it if someone could help me figure out what is causing the error mentioned below.
I have a test Express project with a scripts section in package.json that looks like the following:
"scripts": {
"dev": "backpack",
"build": "backpack build",
"test-server": "babel-node node_modules/.bin/babel-istanbul cover node_modules/.bin/_mocha",
"test-server-ms": "babel-node.cmd node_modules/.bin/babel-istanbul.cmd cover node_modules/.bin/_mocha.cmd"
},
The test-server-ms script is what I am trying to execute:
babel-node.cmd node_modules/.bin/babel-istanbul.cmd cover
node_modules/.bin/_mocha.cmd "test/server"
This yields an error when parsing the babel-istanbul.cmd file:
(function (exports, require, module, __filename, __dirname) { #IF EXIST "%~dp0\node.exe" (
^
SyntaxError: Invalid or unexpected token
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Module._extensions..js (module.js:579:10)
at Object.require.extensions.(anonymous function) [as .js] (C:\Users\hqrsingh\Development\workspaces\vscode\express-es6-starter\node_modules\babel
-register\lib\node.js:152:7)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Function.Module.runMain (module.js:604:10)
at Object.<anonymous> (C:\Users\hqrsingh\Development\workspaces\vscode\express-es6-starter\node_modules\babel-cli\lib\_babel-node.js:154:22)
The error occurs when the #IF directive is encountered which is part of a Windows .cmd script in node_modules\.bin\babel-istanbul.cmd:
#IF EXIST "%~dp0\node.exe" (
"%~dp0\node.exe" "%~dp0\..\babel-istanbul\lib\cli.js" %*
) ELSE (
#SETLOCAL
#SET PATHEXT=%PATHEXT:;.JS;=;%
node "%~dp0\..\babel-istanbul\lib\cli.js" %*
)
I am kicking all of this off within a Windows 7 Pro command shell via npm:
npm run-script test-server-ms test/server
For reference, here is the entire package.json file:
{
"name": "express-es6-starter",
"version": "2.0.0",
"description": "A complete boilerplate for Express.js development including unit test and code coverage.",
"main": "lib/index.js",
"scripts": {
"dev": "backpack",
"build": "backpack build",
"test-server": "babel-node node_modules/.bin/babel-istanbul cover node_modules/.bin/_mocha",
"test-server-ms": "babel-node.cmd node_modules/.bin/babel-istanbul.cmd cover node_modules/.bin/_mocha.cmd"
},
"pre-commit": [
"test-server"
],
"dependencies": {
"express": "^4.14.0"
},
"devDependencies": {
"babel": "^6.23.0",
"babel-cli": "^6.24.1",
"babel-istanbul": "^0.12.2",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.16.0",
"babel-preset-stage-2": "^6.24.1",
"backpack-core": "^0.0.7",
"chai": "^3.5.0",
"karma": "^1.7.0",
"karma-chrome-launcher": "^2.1.1",
"karma-jasmine": "^1.1.0",
"karma-phantomjs-launcher": "^1.0.4",
"mocha": "^3.2.0",
"phantomjs": "^2.1.7",
"pre-commit": "^1.2.2",
"webpack": "^1.14.0"
}
}
FWIW, I was able to solve this by avoiding the use of the babel-* modules entirely. I still do not know how one would go about executing platform specific scripts via npm or if that should even be encouraged.
Here is my entire package.json file:
{
"name": "express-es6-starter",
"version": "2.0.0",
"description": "A complete boilerplate for Express.js development including unit test and code coverage.",
"scripts": {
"start": "node ./build/main.js",
"clean-build": "rm -rf ./build/*",
"dev": "backpack dev",
"build": "backpack build",
"compile": "babel --presets es2015,stage-0 -d build/ src/",
"test-client-karma": "node ./node_modules/karma/bin/karma start karma.conf.js || exit 0",
"test-client-mocha": "mocha test/client/*.js --require babel-register --reporter spec || exit 0",
"test-server": "mocha --compilers js:babel-core/register test/server/**/*.js",
"test": "npm run-script test-server; npm run-script test-client-mocha"
},
"pre-commit": [
"test-server"
],
"dependencies": {
"express": "^4.14.0"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"backpack-core": "^0.0.7",
"brfs": "^1.4.3",
"browserify": "^14.3.0",
"browserify-shim": "^3.8.14",
"chai": "^3.5.0",
"child_process": "^1.0.2",
"jasmine-core": "^2.6.2",
"karma": "^1.7.0",
"karma-chrome-launcher": "^2.1.1",
"karma-browserify": "^5.1.1",
"karma-html-reporter": "^0.2.7",
"karma-jasmine": "^1.1.0",
"karma-mocha": "^1.3.0",
"karma-ng-scenario": "^1.0.0",
"karma-phantomjs-launcher": "^1.0.4",
"mocha": "^3.2.0",
"phantomjs": "^2.1.7",
"pre-commit": "^1.2.2",
"webpack": "^1.14.0",
"watchify": "^3.9.0"
}
}
This is the project structure that the above package.json is based upon: