I want to use npm module "crypto-js" in app.js of truffle_project. But I can't use it.
app.js
:
var CryptoJS = require("crypto-js");
// ...
I build app, then I open build/index.html by browser, I get the error on Javascript console of google chrome:
Uncaught Error: Cannot find module 'crypto-js'
I changed to:
var CryptoJS = require("./node_modules/crypto-js");
or:
var CryptoJS = require("../../node_modules/crypto-js");
but I get the same error. I tried absolute path and relative path, I get the error.
How do I do to use crypto-js
module in app.js
?
P.S. install command:
# pwd
~/truffle_project
# npm install crypto-js
and the directory structure is default of truffle.
npm install
? – Mikko Ohtamaa Jan 29 '17 at 12:15npm install crypto-js
. – taishi Jan 29 '17 at 13:42var CryptoJS = require("crypto-js");
works – Mikko Ohtamaa Jan 29 '17 at 13:43