Can't deploy smart contract application to Heroku - node.js

My application is built with Truffle and React, and I am getting an error when I try to deploy to Heroku. In my local machine all works perfectly, but when I try to deploy:
/tmp/build_e68c9473/node_modules/truffle/build/724.bundled.js:11740
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.__webpack_require__.f.require (/tmp/build_e68c9473/node_modules/truffle/build/cli.bundled.js:624:28)
Error: Error while attempting to download and cache solc 0.5.16: Command failed: node ./build/cli.bundled.js obtain --solc=0.5.16
/tmp/build_e68c9473/node_modules/truffle/build/724.bundled.js:11740
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.__webpack_require__.f.require (/tmp/build_e68c9473/node_modules/truffle/build/cli.bundled.js:624:28)
at postinstallObtain (/tmp/build_e68c9473/node_modules/truffle/scripts/postinstall.js:13:11)
at Object.<anonymous> (/tmp/build_e68c9473/node_modules/truffle/scripts/postinstall.js:20:3)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:188:16)
at bootstrap_node.js:609:3
added 4014 packages in 103.484s
-----> Build
Running build
> mtc-dex#0.2.0 build /tmp/build_e68c9473
> react-scripts build
/tmp/build_e68c9473/node_modules/fs-extra/lib/mkdirs/make-dir.js:85
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/tmp/build_e68c9473/node_modules/fs-extra/lib/mkdirs/index.js:3:44)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mtc-dex#0.2.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mtc-dex#0.2.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /tmp/npmcache.7ibpv/_logs/2021-07-14T09_25_41_172Z-debug.log
-----> Build failed
I see some errors before the build starts, when installing the dependencies. I have the impression something is not OK with truffle when installing it on Heroku, but I am not sure about it. After it, it crashes when doing the build.
I must remark that I was able to run npm run build on my local machine with no errors.
This is my package.json:
{
"name": "mtc-dex",
"version": "0.2.0",
"description": "Decentralized Ethereum Token Exchange",
"author": "miqueltrallero.c#gmail.com",
"private": true,
"homepage": ".",
"engines": {
"node": "10.19.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 11",
"not op_mini all"
],
"dependencies": {
"#reduxjs/toolkit": "^1.6.0",
"#truffle/hdwallet-provider": "^1.4.1",
"apexcharts": "^3.27.1",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-2": "^6.24.1",
"babel-preset-stage-3": "^6.24.1",
"babel-register": "^6.26.0",
"bootstrap": "^5.0.2",
"chai": "^4.3.4",
"chai-as-promised": "^7.1.1",
"chai-bignumber": "^3.0.0",
"dotenv": "^10.0.0",
"lodash": "^4.17.21",
"moment": "^2.29.1",
"openzeppelin-solidity": "^4.2.0",
"react": "^17.0.2",
"react-apexcharts": "^1.3.9",
"react-bootstrap": "^1.6.1",
"react-dom": "^17.0.2",
"react-redux": "^7.2.4",
"react-scripts": "^4.0.3",
"solc": "^0.8.6",
"solidity-coverage": "^0.7.16",
"truffle": "^5.3.14",
"truffle-flattener": "^1.5.0",
"truffle-hdwallet-provider-privkey": "^0.3.0",
"web3": "^1.4.0"
}
}

Make sure you are not including the node_modules folder while deploying. If that is not the case, try setting config vars.

So basically when heroku tries to build your project it run in to an error.
/tmp/build_e68c9473/node_modules/fs-extra/lib/mkdirs/make-dir.js:85
} catch {
^
SyntaxError: Unexpected token {
The most probable cause of this error is that the syntax for try/catch block is as follows:
try {
...
} catch (error) {
...
}
Try to add (error) between the catch and the { everywhere you have try/catch block.

Related

Firebase Functions Node JS: Cannot find module './auth/credential'

After updating to the latest dependencies my Firebase Functions backend won't run in either firebase emulators:start or firebase functions:shell. It fails with the following exception
- C:\Users\yannk\AppData\Roaming\npm\node_modules\firebase-tools\lib\emulator\functionsEmulatorRuntime.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
at Function.Module._load (internal/modules/cjs/loader.js:690:27)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (C:\Project\projdir\firebase\functions\node_modules\firebase-admin\lib\firebase-namespace.js:23:20)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Module.require (internal/modules/cjs/loader.js:852:19) {"metadata":{"emulator":{"name":"functions"},"message":"[runtime-status] [23304] Error in handleMessage: {\"frb\":{\"cwd\":\"C:\\\\Project\\\\projdir\\\\firebase\\\\functions\",\"projectId\":\"snapdiscover-luminarcom\",\"triggerId\":\"\",\"emulators\":{\"firestore\":{\"name\":\"firestore\",\"host\":\"192.168.112.113\",\"port\":8080,\"pid\":23900},\"auth\":{\"name\":\"auth\",\"host\":\"192.168.112.113\",\"port\":9099}},\"adminSdkConfig\":{\"databaseURL\":\"https://snapdiscover-luminarcom.firebaseio.com\",\"storageBucket\":\"snapdiscover-luminarcom.appspot.com\"},\"socketPath\":\"\\\\\\\\?\\\\pipe\\\\C:\\\\Project\\\\projdir\\\\firebase\\\\functions\\\\23304\"},\"opts\":{\"nodeBinary\":\"C:\\\\Program Files\\\\nodejs\\\\node.exe\",\"env\":{}}} => Error: Cannot find module './auth/credential'\nRequire stack:\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-admin\\lib\\firebase-namespace.js\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-admin\\lib\\default-namespace.js\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-admin\\lib\\index.js\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-functions\\lib\\apps.js\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-functions\\lib\\providers\\database.js\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-functions\\lib\\index.js\n- C:\\Users\\yannk\\AppData\\Roaming\\npm\\node_modules\\firebase-tools\\lib\\emulator\\functionsEmulatorRuntime.js: Error: Cannot find module './auth/credential'\nRequire stack:\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-admin\\lib\\firebase-namespace.js\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-admin\\lib\\default-namespace.js\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-admin\\lib\\index.js\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-functions\\lib\\apps.js\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-functions\\lib\\providers\\database.js\n- C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-functions\\lib\\index.js\n- C:\\Users\\yannk\\AppData\\Roaming\\npm\\node_modules\\firebase-tools\\lib\\emulator\\functionsEmulatorRuntime.js\n at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)\n at Function.Module._load (internal/modules/cjs/loader.js:690:27)\n at Module.require (internal/modules/cjs/loader.js:852:19)\n at require (internal/modules/cjs/helpers.js:74:18)\n at Object.<anonymous> (C:\\Project\\projdir\\firebase\\functions\\node_modules\\firebase-admin\\lib\\firebase-namespace.js:23:20)\n at Module._compile (internal/modules/cjs/loader.js:959:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)\n at Module.load (internal/modules/cjs/loader.js:815:32)\n at Function.Module._load (internal/modules/cjs/loader.js:727:14)\n at Module.require (internal/modules/cjs/loader.js:852:19)"}}
[warn] ! functions: Cannot find module './auth/credential'
Require stack:
- C:\Project\projdir\firebase\functions\node_modules\firebase-admin\lib\firebase-namespace.js
- C:\Project\projdir\firebase\functions\node_modules\firebase-admin\lib\default-namespace.js
- C:\Project\projdir\firebase\functions\node_modules\firebase-admin\lib\index.js
- C:\Project\projdir\firebase\functions\node_modules\firebase-functions\lib\apps.js
- C:\Project\projdir\firebase\functions\node_modules\firebase-functions\lib\providers\database.js
- C:\Project\projdir\firebase\functions\node_modules\firebase-functions\lib\index.js
I have tried
Update everything to the latest dependencies (using ncu -u)
Assured that admin.initializeApp() is called
index.ts
import * as admin from 'firebase-admin'
admin.initializeApp()
[...]
I've also tried to initialize the app explicitly
index.ts
import { ServiceAccount, initializeApp, credential } from 'firebase-admin'
import * as serviceAccount from './api-key.json'
initializeApp({
credential: credential.cert(<ServiceAccount>{
projectId: serviceAccount.project_id,
clientEmail: serviceAccount.client_email,
privateKey: serviceAccount.private_key
})
})
[...]
Both give the same error. I need to test my code before deploying it to the backend.
Any help or hint is appreciated. Thanks
Edit: Now I get a new error:
[warn] ! TypeError: util.assign is not a function
at Object.<anonymous> (C:\Project\projdir\firebase\functions\node_modules\qs\lib\formats.js:13:23)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
at Module.load (internal/modules/cjs/loader.js:815:32)
at Function.Module._load (internal/modules/cjs/loader.js:727:14)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (C:\Project\projdir\firebase\functions\node_modules\qs\lib\utils.js:3:15)
at Module._compile (internal/modules/cjs/loader.js:959:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10) {"metadata":{"emulator":{"name":"functions"},"message":"TypeError: util.assign is not a function\n at Object.<anonymous> (C:\\Project\\projdir\\firebase\\functions\\node_modules\\qs\\lib\\formats.js:13:23)\n at Module._compile (internal/modules/cjs/loader.js:959:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)\n at Module.load (internal/modules/cjs/loader.js:815:32)\n at Function.Module._load (internal/modules/cjs/loader.js:727:14)\n at Module.require (internal/modules/cjs/loader.js:852:19)\n at require (internal/modules/cjs/helpers.js:74:18)\n at Object.<anonymous> (C:\\Project\\projdir\\firebase\\functions\\node_modules\\qs\\lib\\utils.js:3:15)\n at Module._compile (internal/modules/cjs/loader.js:959:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)"}}
This is my package.json
{
"name": "functions",
"scripts": {
"lint": "tslint --project tsconfig.json",
"build": "tsc",
"serve": "npm run build && firebase emulators:start --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log",
"test": "mocha --reporter spec"
},
"engines": {
"node": "10"
},
"main": "lib/index.js",
"dependencies": {
"#types/axios": "^0.14.0",
"axios": "^0.21.1",
"bad-words": "^3.0.4",
"capitalize-sentence": "^0.1.5",
"crypto": "^1.0.1",
"firebase-admin": "^9.6.0",
"firebase-functions": "^3.13.2",
"firebase-tools": "^9.8.0",
"perspective-api-client": "^3.1.0",
"qs": "^6.10.1"
},
"devDependencies": {
"firebase-functions-test": "^0.2.3",
"mocha": "^8.3.2",
"tslint": "^5.20.1",
"typescript": "^4.2.3"
},
"private": true
}

Cannot find module 'loadash'

I am getting the following error on executing command: npm start
Cannot find module 'loadash'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (<Path...>/data/dbConnector.js:3:1)
at Module._compile (module.js:643:30)
at loader (<Path...>\node_modules\babel-register\lib\node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (<Path...>\node_modules\babel-register\lib\node.js:154:7)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (<Path...>/data/resolvers.js:2:1)
at Module._compile (module.js:643:30)
at loader (<Path...>\node_modules\babel-register\lib\node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (<Path...>\node_modules\babel-register\lib\node.js:154:7)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
[nodemon] app crashed - waiting for file changes before starting...
package.json file:
{
"name": "essentials",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "nodemon ./index.js --exec babel-node -e js"
},
"author": "test",
"license": "ISC",
"dependencies": {
"casual": "^1.5.19",
"express": "^4.16.3",
"express-graphql": "^0.6.12",
"graphql": "^0.13.2",
"graphql-tools": "^2.23.1",
"loadash": "^1.0.0",
"mongoose": "^5.0.12",
"nodemon": "^1.17.2",
"sequelize": "^4.37.5",
"sqlite3": "^4.0.0"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-stage-0": "^6.24.1"
}
}
I followed the below links but still none of them are working for me.
https://stackoverflow.com/questions/27431187/cannot-find-module-lodash
https://stackoverflow.com/questions/27431187/cannot-find-module-lodash/36618374
Also I see the below warning message:
Problems loading reference 'https://schemastore.azurewebsites.net/schemas/json/package.json': Unable to load schema from 'https://schemastore.azurewebsites.net/schemas/json/package.json': Unable to connect to https://schemastore.azurewebsites.net/schemas/json/package.json. Error: self signed certificate in certificate chain
Can anyone help me to fix this issue?
The package name should be lodash, not loadash.
After you correct that in packages.json you need to execute npm install.

"Unexpected token {" when using npx babel-node

Here is my script test.js:
import 'jsdom-global/register';
import 'canvas';
console.log('done');
And here is my package.json:
{
"name": "test-jsdom",
"description": "Test",
"version": "0.1.0",
"author": "anthony#me.com",
"dependencies": {
"canvas": "^1.6.7"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.6.1",
"babel-preset-stage-0": "^6.24.1",
"jsdom": "^11.3.0",
"jsdom-global": "^3.0.2"
}
}
When I run npx babel-node test.js, I encountered this error
/Users/antkong/test/node_modules/jsdom/lib/api.js:10
const { URL } = require("whatwg-url");
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Module._extensions..js (module.js:416:10)
at Object.require.extensions.(anonymous function) [as .js] (/Users/antkong/test/node_modules/babel-register/lib/node.js:152:7)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at globalJsdom (/Users/antkong/test/node_modules/jsdom-global/index.js:28:15)
at Object.<anonymous> (/Users/antkong/test/node_modules/jsdom-global/register.js:1:19)
And it is my .babelrc file
{
"presets": ["env", "stage-0"]
}
It seems to me babel-node cannot handle es6 syntax in the dependent js file. I expect babel-node to be able to load and compile all dependency on the fly. How can I fix this problem?
Version info:
$ node --version
v4.8.6
$ npm --version
2.15.11
Should use more up to date version of node.
I use nvm to switch node to version 8.7.0 and the issue is fixed.

Error: Cannot find module 'babel-core/register'

I have following error when trying to run my app on Heroku
Error: Cannot find module 'babel-core/register'
2017-11-13T10:42:19.749689+00:00 app[web.1]: at Function.Module._resolveFilename (module.js:469:15)
2017-11-13T10:42:19.749690+00:00 app[web.1]: at Function.Module._load (module.js:417:25)
2017-11-13T10:42:19.749691+00:00 app[web.1]: at Module.require (module.js:497:17)
2017-11-13T10:42:19.749691+00:00 app[web.1]: at require (internal/module.js:20:19)
2017-11-13T10:42:19.749692+00:00 app[web.1]: at Object.<anonymous> (/app/bootstrap.js:1:63)
2017-11-13T10:42:19.749692+00:00 app[web.1]: at Module._compile (module.js:570:32)
2017-11-13T10:42:19.749693+00:00 app[web.1]: at Object.Module._extensions..js (module.js:579:10)
2017-11-13T10:42:19.749694+00:00 app[web.1]: at Module.load (module.js:487:32)
2017-11-13T10:42:19.749694+00:00 app[web.1]: at tryModuleLoad (module.js:446:12)
2017-11-13T10:42:19.749695+00:00 app[web.1]: at Function.Module._load (module.js:438:3)
My package.json file is:
{
"name": "birdbase",
"version": "1.0.0",
"devDependencies": {
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-es2015": "^6.18.0"
},
"dependencies": {
"babel-register": "^6.26.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-es2015": "^6.18.0",
"bell": "^8.7.0",
"hapi": "^16.0.1",
"hapi-auth-jwt": "^4.0.0",
"jsonwebtoken": "^8.1.0",
"knex": "^0.14.0",
"mysql": "^2.14.1",
"node-uuid": "^1.4.8"
},
"scripts": {
"start": "node bootstrap.js"
}
}
and my app is based on the following tutorial:
https://scotch.io/tutorials/making-a-restful-api-with-hapi-js
src: https://github.com/labsvisual/hapijs-birds-api
So package.json dependencies are same as in devDependencies (as was indicated on other Stack Overflow issues).
Any idea why there is an error?

Webpack Breaks Mocha in Node.js App

I have a node.js app that uses Mocha and Expect for testing. All the tests work great, until I installed webpack for react. Now when I run "npm test" I get the following error:
Error: Cannot find module 'should'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\Brian\version-control\tysons-tech-map-redone\node_modules\watchpack\test\DirectoryWatcher.test.js:2:1)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at C:\Users\Brian\version-control\tysons-tech-map-redone\node_modules\mocha\lib\mocha.js:230:27
at Array.forEach (native)
at Mocha.loadFiles (C:\Users\Brian\version-control\tysons-tech-map-redone\node_modules\mocha\lib\mocha.js:227:14)
at Mocha.run (C:\Users\Brian\version-control\tysons-tech-map-redone\node_modules\mocha\lib\mocha.js:495:10)
at Object.<anonymous> (C:\Users\Brian\version-control\tysons-tech-map-redone\node_modules\mocha\bin\_mocha:469:18)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:393:7)
at startup (bootstrap_node.js:150:9)
at bootstrap_node.js:508:3
npm ERR! Test failed. See above for more details.
Below is my package.json:
{
"name": "cool-map",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "node server.js",
"test": "export NODE_ENV=test || SET \"NODE_ENV=test\" && mocha **/*.test.js",
"test-watch": "nodemon --exec \"npm test\""
},
"engines": {
"node": "6.2.2"
},
"license": "ISC",
"dependencies": {
"bcryptjs": "^2.3.0",
"body-parser": "^1.15.2",
"express": "^4.14.0",
"jsonwebtoken": "^7.1.9",
"lodash": "^4.15.0",
"mongodb": "^2.2.5",
"mongoose": "^4.5.9",
"validator": "^5.6.0",
"hbs": "^4.0.0",
"babel-preset-stage-0": "^6.24.1",
"express": "^4.15.2",
"react": "^0.14.7",
"react-dom": "^0.14.7"
},
"devDependencies": {
"expect": "^1.20.2",
"mocha": "^3.0.2",
"nodemon": "^1.10.2",
"supertest": "^2.0.0",
"babel-core": "^6.5.1",
"babel-loader": "^6.2.2",
"babel-preset-es2015": "^6.5.0",
"babel-preset-react": "^6.5.0",
"webpack": "^1.12.13"
}
}
I'm not sure if webpack.config is necessary to post, but just in case:
module.exports = {
entry: './app/app.jsx',
output: {
path: __dirname,
filename: './public/bundle.js'
},
resolve: {
root: __dirname,
alias: {
AdminUserTable: 'app/components/AdminUserTable.jsx'
},
extensions: ['', '.js', '.jsx']
},
module: {
loaders: [
{
loader: 'babel-loader',
query: {
presets: ['react', 'es2015']
},
test: /\.jsx?$/,
exclude: /(node_modules|bower_components)/
}
]
}
};
Running the command npm test works great when I uninstall webpack, I'm not sure why It's breaking mocha.
Your package.json is missing should as a dependency.
Install it via;
npm install --save-dev should
Also I would recommend you look into chai which in my opinion provides a slightly different API.
should is an expressive, readable, framework-agnostic assertion library. The main goals of this library are to be expressive and to be helpful. It keeps your test code clean, and your error messages helpful.
By default (when you require('should')) should extends the Object.prototype with a single non-enumerable getter that allows you to express how that object should behave. It also returns itself when required with require.
It is also possible to use should.js without getter (it will not even try to extend Object.prototype), just require('should/as-function'). Or if you already use version that auto add getter, you can call .noConflict function.
Results of (something).should getter and should(something) in most situations are the same
Better u install node dependency should with npm as below
npm install --save should
should-reference

Resources