How to solve “Module not found: Error: Can't resolve 'truffle-contract'” error in web3?

+1 vote

I am trying to work on truffle-contract and web3 but I am facing problem when I execute the npm run dev command. The error is as follows:

ERROR in ./app/javascripts/app.js
Module not found: Error: Can't resolve 'truffle-contract' in 'C:\Users\edureka\Desktop\SID\ALSC\PROJECT\asset-lending\app\javascripts'
 @ ./app/javascripts/app.js 6:1-55
 @ multi (webpack)-dev-server/client?http://localhost:8080 ./app/javascripts/app.js

ERROR in ./app/javascripts/app.js
Module not found: Error: Can't resolve 'web3' in 'C:\Users\edureka\Desktop\SID\ALSC\PROJECT\asset-lending\app\javascripts'
 @ ./app/javascripts/app.js 5:1-39
 @ multi (webpack)-dev-server/client?http://localhost:8080 ./app/javascripts/app.js
webpack: Failed to compile.

How to solve this error?

Jul 26, 2018 in Blockchain by slayer
• 29,040 points
723 views

3 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
+2 votes
Best answer

Try compiling and migrating the contract:

$ truffle compile
$ truffle migrate
answered Apr 30 by Rachita

selected Apr 30 by Omkar
+1 vote

Execute the following command:

$ npm install truffle-contract

It should solve your error. If it does not then try installing truffle-contract globally like this:

$ npm install -g truffle-contract

 To know more visit: https://www.npmjs.com/package/truffle-contract

answered Jul 26, 2018 by digger
• 27,620 points
+1 vote

Maybe there are missing necessary files. Try getting react.

$ truffle unbox react
answered Apr 30 by Jashn

Related Questions In Blockchain

+1 vote
5 answers

How to solve "truffle: command not found" error in blockchain?

First try restarting the system and then ...READ MORE

answered Jul 16, 2018 in Blockchain by slayer
• 29,040 points
570 views
0 votes
1 answer
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
77 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
10 answers

How to solve gradle build failed error?

I migrated the project to a different ...READ MORE

answered Dec 7, 2018 in Blockchain by Rajat
4,229 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.