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,370 points
7,560 views

3 answers to this question.

+2 votes
Best answer

Try compiling and migrating the contract:

$ truffle compile
$ truffle migrate
answered Apr 30, 2019 by Rachita

selected Apr 30, 2019 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
• 26,740 points
+1 vote

Maybe there are missing necessary files. Try getting react.

$ truffle unbox react
answered Apr 30, 2019 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,370 points
11,857 views
0 votes
1 answer

Module not found: Can't resolve './truffle-contract/build/contracts

Hey! Firstly, there seems to be a ...READ MORE

answered May 9, 2019 in Blockchain by Omkar
• 69,230 points
2,923 views
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
1,885 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,402 views
0 votes
1 answer

How to manually create the instance of the contract in truffle?

You can try to do it like ...READ MORE

answered Sep 24, 2018 in Blockchain by slayer
• 29,370 points
2,676 views
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
48,725 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP