I've checked that the connect-privkey-to-provider module is in the dependencies. However, it keeps saying Module 'connect-privkey-to-provider' is extraneous npm and cannot find module 'connect-privkey-to-provider'.
What's wrong with my code?
PS C:\Users\1Sun\addition-game-starter> truffle deploy --network
klaytn
Error: Cannot find module 'connect-privkey-to-provider'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (C:\Users\1Sun\addition-game-starter\truffle.js:2:29)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Function.Config.load (C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-config\index.js:254:1)
at Function.Config.detect (C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-config\index.js:243:1)
at Object.run (C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-core\lib\commands\migrate.js:35:1)
at Command.run (C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-core\lib\command.js:101:1)
at Object. (C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\webpack:\packages\truffle-core\cli.js:22:1)
at webpack_require (C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\webpack:\webpack\bootstrap
0791995565e53f633c90:19:1)
at C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\webpack:\webpack\bootstrap
0791995565e53f633c90:65:1
at Object. (C:\Users\1Sun\AppData\Roaming\npm\node_modules\truffle\build\cli.bundled.js:71:10)
at Module._compile (internal/modules/cjs/loader.js:701:30)
package.json
{
"name": "klay-dapp-boilerplate",
"version": "0.0.1",
"description": "boilerplate for klaytn-based app",
"main": "truffle.js",
"scripts": {
"build": "webpack",
"dev": "webpack-dev-server"
},
"dependencies": {
"caver-js": "^0.0.2-m",
"connect-privkey-to-provider": "^0.0.3",
"spin.js": "^4.0.0"
},
"devDependencies": {
"copy-webpack-plugin": "^4.6.0",
"eslint": "^4.19.1",
"webpack": "^4.7.0",
"webpack-cli": "^3.1.1",
"webpack-dev-server": "^3.1.4"
},
"eslintConfig": {
"env": {
"browser": true,
"node": true
}
}
}
truffle.js
// truffle.js config for klaytn.
const PrivateKeyConnector = require('connect-privkey-to-provider')
const NETWORK_ID = '1001'
const GASLIMIT = '20000000'
const URL ='https://api.baobab.klaytn.net:8651'
const PRIVATE_KEY = '0x80ea7e298ba2cbf484e6c0c0703ccf2ea94be7f8a1a097fc013042b4888a2e80'
module.exports = {
networks: {
klaytn: {
provider: new PrivateKeyConnector(PRIVATE_KEY, URL),
network_id: NETWORK_ID,
gas: GASLIMIT,
gasPrice: null,
}
}
}
Error
Your code works fine in my environment. Try to do these:
Remove node_modules
Remove package-lock.json
Update truffle package npm update -g truffle
Reinstall, using command npm i
After that just change solidity version in contracts folder
pragma solidity ^0.5.0;
In my case for changing some dependencies, I was deleting node_modules, but I had to erase package-lock.json too.
I closed all windows, deleted node_modules folder and package-lock.json and reinstalled it all again with npm install.
Related
I've encountered the following error while using eslint command in my project:
$ eslint ./src/ --max-warnings 69 --ext .js,.jsx,.ts,.tsx
Oops! Something went wrong! :(
ESLint: 7.7.0
.../node_modules/language-tags/lib/Tag.js:17
static ERR_DEPRECATED = 1;
^
SyntaxError: Unexpected token =
at new Script (vm.js:83:7)
at NativeCompileCache._moduleCompile (.../node_modules/v8-compile-cache/v8-compile-cache.js:240:18)
at Module._compile (.../node_modules/v8-compile-cache/v8-compile-cache.js:184:36)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (.../node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
at Object.<anonymous> (.../node_modules/language-tags/lib/index.js:11:11)
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I am using the following plugins and configs for eslint:
{
"#typescript-eslint/eslint-plugin": "4.15.2",
"#typescript-eslint/parser": "4.15.2",
"eslint": "7.7.0",
"eslint-config-airbnb": "18.2.1",
"eslint-config-airbnb-typescript": "9.0.0",
"eslint-config-prettier": "8.3.0",
"eslint-import-resolver-typescript": "2.4.0",
"eslint-plugin-cypress": "2.12.1",
"eslint-plugin-dirnames": "1.0.3",
"eslint-plugin-import": "2.23.4",
"eslint-plugin-jsx-a11y": "6.4.1",
"eslint-plugin-prettier": "3.4.0",
"eslint-plugin-react": "7.24.0",
"eslint-plugin-react-hooks": "4.2.0",
"eslint-plugin-simple-import-sort": "5.0.3",
"eslint-plugin-unicorn": "18.0.1"
}
I've tried to reproduce the correct package configuration which worked fine before I started switching my project from npm to yarn v1 (this problem happened because of that). But current yarn.lock is about 25000 lines long and it is tough to compare it to package-lock.json.
I solved this problem by myself eventually and want to share the solution.
The problem lied in the eslint-plugin-jsx-a11y#6.4.1 package.
Its dependencies are listed below:
dependencies:
"#babel/runtime" "^7.11.2"
aria-query "^4.2.2"
array-includes "^3.1.1"
ast-types-flow "^0.0.7"
axe-core "^4.0.2"
axobject-query "^2.2.0"
damerau-levenshtein "^1.0.6"
emoji-regex "^9.0.0"
has "^1.0.3"
jsx-ast-utils "^3.1.0"
language-tags "^1.0.5"
As it turns out, yarn v1 resolved the dependency language-tags#^1.0.5 as language-tags#1.0.7 which caused the eslint command to stop working altogether.
language-tags#^1.0.5:
version "1.0.7"
resolved ".../npm/language-tags/-/language-tags-1.0.7.tgz#41cc248730f3f12a452c2e2efe32bc0bbce67967"
integrity ...
dependencies:
language-subtag-registry "^0.3.20"
So the solution is to either change the version of language-tags in your lock file from 1.0.7 to 1.0.5 or provide a yarn resolution where you would specify the desired package version
"resolutions": {
"language-tags": "1.0.5"
}
I'm trying to create an application that depends on Express, but Cpanel just won't install it. I've contacted Namecheap, followed all their instruction and tried all kinds of things, but haven't had any success.
This is my package.json file
{
"name": "server",
"version": "1.0.0",
"main": "app.js",
"scripts": {
"start": "node app.js"
},
"author": "",
"license": "ISC",
"description": "",
"dependencies": {
"axios": "^0.27.2",
"cors": "^2.8.5",
"dotenv": "^16.0.1",
"express": "^4.17.2",
"mysql2": "^2.3.3",
"puppeteer": "^15.3.2"
}
}
After running "npm install" and having no apparent errors, I find this in the stderr.log file:
- Error: Cannot find module 'express'
- Require stack:
- /home/<user>/public_html/api/app.js
- /usr/local/lsws/fcgi-bin/lsnode.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:93:18)
at Object.<anonymous> (/home/<user>/public_html/api/app.js:3:17)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at Module.require (internal/modules/cjs/loader.js:974:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/<user>/public_html/api/app.js',
'/usr/local/lsws/fcgi-bin/lsnode.js'
]
}
For some reason Express won't install. I've destroyed the application and tried all over again, but the same problem arises.
Node version is 14.18.3.
I'm hoping someone who knows what's going on can help me.
I am trying to install babel watch after I have installed babel
my json file is as follows
{
"name": "t3",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "babel server.js --out-dir build",
"dev-start": "babel-watch server.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"express": "^4.17.1"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-watch": "^7.0.0"
}
}
but i am getting this error while running
npm run dev-start
t3#1.0.0 dev-start C:\Users\PRO\Desktop\t3
babel-watch server.js
internal/modules/cjs/loader.js:583
throw err;
^
Error: Cannot find module '#babel/core'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object. (C:\Users\PRO\Desktop\t3\node_modules\babel-watch\babel-watch.js:7:15)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! t3#1.0.0 dev-start:
babel-watch server.js npm ERR! Exit status 1 npm ERR! npm ERR!
Failed at the t3#1.0.0 dev-start script. npm ERR! This is probably not
a problem with npm. There is likely additional logging output above.
[Update]
You might have update the babel. check out https://github.com/babel/babel/issues/8908 & How to upgrade to babel 7
Try
npm install #babel/core --save
I have the experience with ReactJS and I have built the web app with react.
But I have seen the home automation from deepsyx
https://github.com/deepsyx/home-automation
I have tried to run server in "server" directory but it's error
me:server mai$ node index.js
internal/modules/cjs/loader.js:584
throw err;
^
Error: Cannot find module 'home-config'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/Users/mai/Documents/Workspace/home-automation/server/index.js:13:20)
at Module._compile (internal/modules/cjs/loader.js:701:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
at Module.load (internal/modules/cjs/loader.js:600:32)
at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
at Function.Module._load (internal/modules/cjs/loader.js:531:3)
How to fix this error?
This project is very cool, Anybody has the step to run this project?
Thanks in advance !!!!
me:server mai$ cat package.json
{
"name": "home-automation",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "Viktor Kirilov (deepsybg#gmail.com)",
"license": "MIT",
"dependencies": {
"home-config": "file:../home-config",
"home-records": "file:../home-records",
"ws": "1.1.1"
}
}
I've got it to run React Home Automation Server.
I hope this could help all newbie like me to do the home automation on Raspberry Pi.
I found 2 steps:
I found the problem that it cannot find "home-config" directory so I go to "home-config" directory and copy "index.example.js" to "index.js".
In the virtualbox need to add "../" to const homeConfig =
require('../home-config'); from const homeConfig = require('home-config'); but cannot run anyway because of not raspberry pi environment.
I get the error from running temperature sensor "DS18B20", then I fix const deviceFolder = files.find(file => /^10/.test(file)); to const deviceFolder = files.find(file => /^28/.test(file)); in "server/utils/temperature.js" because my raspberry pi 3 generate "28-01131faf1feb directory.
I have a very simple code written in es6
import { scale } from 'd3-scale';
const a = scale.scalePow().domain([0, 20]).range([0, 1, 2, 30, 560, 1]);
console.log(a(1));
The dependency 'd3-scale' can be installed by
npm install d3-scale --save
I ran the following command to execute the script:
npx babel-node scale_words.js
And I got this error:
/Users/antkong/scale_series.js:1
(function (exports, require, module, __filename, __dirname) { import { scale } from 'd3-scale';
^^^^^^
SyntaxError: Unexpected token import
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:588:28)
at loader (/Users/antkong/node_modules/babel-register/lib/node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/antkong/node_modules/babel-register/lib/node.js:154:7)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Function.Module.runMain (module.js:665:10)
at Object.<anonymous> (/Users/antkong/node_modules/babel-cli/lib/_babel-node.js:154:22)
I do not expect this error at all. The import statement looks normal to me.
Here is the package.json
{
"name": "test",
"description": "Test",
"version": "0.1.0",
"dependencies": {
"d3-scale": "^1.0.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"
}
}
I am using
node v8.7.0
and
npm 5.5.1
I have tried rerun npm install but it does not fix the problem. In the same folder I have another script with these import statements
import 'jsdom-global/register';
import 'canvas';
import { EventEmitter } from 'events';
And it can be run with npx babel-node alright
If I use alternative syntax, it can run without any issue
var d3Scale = require("d3-scale")
var a = d3Scale.scalePow().domain([0, 20]).range([0, 1, 2, 30, 560, 1]);
;
console.log(a(1))
There is a only entry in the .babelrc in the same folder. It excludes the scale_words.js from being executed as an es6 file.