After running npm install
, I have noticed that sometimes package-lock.json
changes.
This section:
"dependencies": {
"websocket": {
"version": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
"from": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
"requires": {
"debug": "^2.2.0",
"nan": "^2.3.3",
"typedarray-to-buffer": "^3.1.2",
"yaeti": "^0.0.6"
}
}
}
}
Changes to this:
"dependencies": {
"websocket": {
"version": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
"from": "git://github.com/frozeman/WebSocket-Node.git#6c72925e3f8aaaea8dc8450f97627e85263999f2",
"requires": {
"debug": "^2.2.0",
"nan": "^2.3.3"
}
}
}
}
And when that happens, I get a runtime error:
module.js:538
throw err;
^
Error: Cannot find module 'typedarray-to-buffer'
at Function.Module._resolveFilename (module.js:536:15)
at Function.Module._load (module.js:466:25)
at Module.require (module.js:579:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\...\node_modules\web3-providers-ws\node_modules\websocket\lib\W3CWebSocket.js:18:16)
at Module._compile (module.js:635:30)
at Object.Module._extensions..js (module.js:646:10)
at Module.load (module.js:554:32)
at tryModuleLoad (module.js:497:12)
at Function.Module._load (module.js:489:3)
After some debugging, this error is for require("web3")
in my code.
Here is the relevant section in my package.json
file:
"devDependencies": {
"chai": "^4.1.2",
"chai-as-promised": "^7.0.0",
"bignumber.js": "^7.0.0",
"decimal.js": "^10.0.0",
"web3": "1.0.0-beta.34",
"ethereumjs-testrpc-sc": "6.1.2",
"ganache-cli": "6.1.0",
"solidity-coverage": "0.4.14",
"truffle": "4.1.3"
}
Can anyone please advise how I may resolve this, and why npm
works differently from time to time?
Thank you.