tried running npx hardhat node
this is the error I got
Error HH604: Error running JSON-RPC server: error:0308010C:digital envelope routines::unsupported
For more info go to https://hardhat.org/HH604 or run Hardhat with --show-stack-traces
here is my config file.
require('dotenv').config();
require("#nomiclabs/hardhat-ethers");
const KOVAN_RPC_URL = process.env.KOVAN_RPC_URL;
const PRIVATE_KEY = process.env.PRIVATE_KEY;
module.exports = {
defaultNetwork: "hardhat",
networks: {
hardhat: {
},
kovan: {
url: KOVAN_RPC_URL,
accounts: [PRIVATE_KEY]
}
},
solidity: {
version: "0.8.0",
settings: {
optimizer: {
enabled: true,
runs: 200
}
}
},
paths: {
sources: "./contracts",
tests: "./test",
cache: "./cache",
artifacts: "./artifacts"
},
mocha: {
timeout: 20000
}
}
To solve this, you need to update your package.json with export SET NODE_OPTIONS=--openssl-legacy-provider
"scripts": {
"start": "export SET NODE_OPTIONS=--openssl-legacy-provider && npx hardhat node"
},
Then, you can just run yarn start or export SET NODE_OPTIONS=--openssl-legacy-provider && npx hardhat node
https://github.com/webpack/webpack/issues/14532#issuecomment-951378874
I am new to javascript I was trying to run some repositories from GitHub, I have installed all the necessary updates also done npm audit --force but still I am getting this error. Any help will be appreciated.
Code :
PS D:\agario clone\agar.io-clone-master> npm start
> agar-clone#1.0.0 start D:\agario clone\agar.io-clone-master
> gulp run
AssertionError [ERR_ASSERTION]: Task function must be specified
at Gulp.set [as _setTask] (D:\agario clone\agar.io-clone-master\node_modules\undertaker\lib\set-task.js:10:3)
at Gulp.task (D:\agario clone\agar.io-clone-master\node_modules\undertaker\lib\task.js:13:8)
at Object.<anonymous> (D:\agario clone\agar.io-clone-master\gulpfile.js:13:6)
at Module._compile (internal/modules/cjs/loader.js:1072:14)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
at Module.load (internal/modules/cjs/loader.js:937:32)
at Function.Module._load (internal/modules/cjs/loader.js:778:12)
at Module.require (internal/modules/cjs/loader.js:961:19)
at require (internal/modules/cjs/helpers.js:92:18)
at requireOrImport (D:\agario clone\agar.io-clone-master\node_modules\gulp\node_modules\gulp-cli\lib\shared\require-or-import.js:19:11) {
generatedMessage: false,
code: 'ERR_ASSERTION',
actual: false,
expected: true,
operator: '=='
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! agar-clone#1.0.0 start: `gulp run`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the agar-clone#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\cordt\AppData\Roaming\npm-cache\_logs\2021-09-27T11_34_53_151Z-debug.log
Here is my gulpfile.js
var gulp = require('gulp');
var babel = require('gulp-babel');
var jshint = require('gulp-jshint');
var nodemon = require('gulp-nodemon');
var uglify = require('gulp-uglify');
var util = require('gulp-util');
var mocha = require('gulp-mocha');
var todo = require('gulp-todo');
var webpack = require('webpack-stream');
var fs = require('fs');
gulp.task('build', ['build-client', 'build-server', 'test']);
gulp.task('test', ['lint'], function () {
gulp.src(['test/**/*.js'])
.pipe(mocha());
});
gulp.task('lint', function () {
return gulp.src(['**/*.js', '!node_modules/**/*.js', '!bin/**/*.js'])
.pipe(jshint({
esnext: true
}))
.pipe(jshint.reporter('default', { verbose: true}))
.pipe(jshint.reporter('fail'));
});
gulp.task('build-client', ['lint', 'move-client'], function () {
return gulp.src(['src/client/js/app.js'])
.pipe(uglify())
.pipe(webpack(require('./webpack.config.js')))
.pipe(babel({
presets: [
['es2015', { 'modules': false }]
]
}))
.pipe(gulp.dest('bin/client/js/'));
});
gulp.task('move-client', function () {
return gulp.src(['src/client/**/*.*', '!client/js/*.js'])
.pipe(gulp.dest('./bin/client/'));
});
gulp.task('build-server', ['lint'], function () {
return gulp.src(['src/server/**/*.*', 'src/server/**/*.js'])
.pipe(babel())
.pipe(gulp.dest('bin/server/'));
});
gulp.task('watch', ['build'], function () {
gulp.watch(['src/client/**/*.*'], ['build-client', 'move-client']);
gulp.watch(['src/server/*.*', 'src/server/**/*.js'], ['build-server']);
gulp.start('run-only');
});
gulp.task('todo', ['lint'], function() {
gulp.src('src/**/*.js')
.pipe(todo())
.pipe(gulp.dest('./'));
});
gulp.task('run', ['build'], function () {
nodemon({
delay: 10,
script: './server/server.js',
cwd: "./bin/",
args: ["config.json"],
ext: 'html js css'
})
.on('restart', function () {
util.log('server restarted!');
});
});
gulp.task('run-only', function () {
nodemon({
delay: 10,
script: './server/server.js',
cwd: "./bin/",
args: ["config.json"],
ext: 'html js css'
})
.on('restart', function () {
util.log('server restarted!');
});
});
gulp.task('default', ['run']);
I am using this repo if you want to take a look at it? https://github.com/huytd/agar.io-clone
I have FOUND this helpfull for migration to Gulp#4.0.0
https://www.sitepoint.com/how-to-migrate-to-gulp-4/
I'm trying to create VS Code extension. It works when fine when I develop, however when I create the package and install it to VS Code it is failing with following error:
ERR Cannot find module 'request': Error: Cannot find module 'request'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:602:15)
at Function.Module._load (internal/modules/cjs/loader.js:528:25)
at Function.t._load (c:\Users\USER\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:729:537)
at Function.t.getExtensionPathIndex.then.a._load (c:\Users\USER\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:691:639)
at Function.t.getExtensionPathIndex.then.r._load (c:\Users\USER\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\workbench\services\extensions\node\extensionHostProcess.js:655:197)
at Module.require (internal/modules/cjs/loader.js:658:17)
at n (c:\Users\USER\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js:15:874)
at openBambooPlanUrlInBrowser.GIT.getGitBranchFromFileName (C:\Users\USER\.vscode\extensions\dUSER.markdown-table-of-contents-0.0.1\out\extension.js:397:41)
at getGitBranchFromFileName.exec (C:\Users\USER\.vscode\extensions\dUSER.markdown-table-of-contents-0.0.1\out\extension.js:383:17)
at ChildProcess.exithandler (child_process.js:294:7)
at ChildProcess.emit (events.js:182:13)
at maybeClose (internal/child_process.js:961:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:248:5)
my code:
async openBambooPlanUrlInBrowser(fileName: string) {
new GIT().getGitBranchFromFileName(fileName, (branch: string) => {
var config: any = vscode.workspace.getConfiguration('markdown-table-of-contents').get('bitbucketRepositories');
for (var setting of config) {
if (fileName.toLowerCase().startsWith(setting.folder.toLowerCase())) {
branch = branch.replace('/', '-');
let bambooHost = vscode.workspace.getConfiguration('markdown-table-of-contents').get('atlassianBambooHost');
const request = require('request');
request(
{
url: `${bambooHost}/rest/api/latest/plan/${setting.bambooPlanKey}/branch/${branch}.json`,
headers: {
"Authorization": 'Basic ' + vscode.workspace.getConfiguration('markdown-table-of-contents').get('atlassianAuthHash')
}
},
(error: string, response: string, body: string) => {
let planKey = JSON.parse(body).key;
vscode.env.openExternal(vscode.Uri.parse(`${bambooHost}/browse/${planKey}`));
}
);
}
}
});
}
dependencies from package.json
"dependencies": {
"child_process": "^1.0.2",
"clipboardy": "^1.2.3",
"fs": "0.0.1-security",
"iconv-lite": "^0.4.24",
"path": "^0.12.7",
"request": "^2.88.0",
"util": "^0.11.1",
"xml2js": "^0.4.19",
"xmldom": "^0.1.27"
}
root folder:
.gitignore
.vscode
.vscodeignore
depl.bat
markdown-table-of-contents-0.0.1.vsix
node_modules
out
package-lock.json
package.json
src
tsconfig.json
tslint.json
For me the solution was to run npm install <package_name> (notice no "-g") from the extension's code root folder. Vscode puts the extension in its [extension folder][1], navigate there to do npm install.
Example: for linux/mac
cd ~/.vscode/extensions
cd your.extension
npm install
This automatically added it to the devDependencies as well, and the extension worked perfectly from there on.
I have this in my package.json
script: {
"myscript": "babel-node script.js"
}
In the terminal I do npm run myscript my-param. I'm able to get
my-param in script.js, I have this in script.js
const argv = require('yargs').argv
const { _ : [ my_param ] } = argv
console.log(my_param)
But if I chain my npm script like so
script: {
"myscript": "babel-node script.js && node_modules/karma/bin/karma start karma.config.js"
}
Then I can't pass anything using npm run myscript.js script.js from the terminal anymore? I don't see my-param in the console.log
I have imported a reacted project in my computer. It gives me an error in console when I try to run the gulp command. But at the same time when I run it on ubuntu, it works perfectly fine. This is the error I am getting on windows
ERROR in ./src/client/index.js
Module parse failed: D:\Frontend-Master\src\client\index.js Unexpected token (64:2)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (64:2)
at Parser.pp$4.raise (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:2221:15)
at Parser.pp.unexpected (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:603:10)
at Parser.pp$3.parseExprAtom (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1822:12)
at Parser.pp$3.parseExprSubscripts (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1715:21)
at Parser.pp$3.parseMaybeUnary (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1692:19)
at Parser.pp$3.parseExprOps (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1637:21)
at Parser.pp$3.parseMaybeConditional (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1620:21)
at Parser.pp$3.parseMaybeAssign (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1597:21)
at Parser.pp$3.parseExprList (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:2165:22)
at Parser.pp$3.parseSubscripts (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1741:35)
at Parser.pp$3.parseExprSubscripts (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1718:17)
at Parser.pp$3.parseMaybeUnary (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1692:19)
at Parser.pp$3.parseExprOps (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1637:21)
at Parser.pp$3.parseMaybeConditional (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1620:21)
at Parser.pp$3.parseMaybeAssign (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1597:21)
at Parser.pp$3.parseExpression (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1573:21)
# multi main
-- client bundled.
Hash: f58f7ad4ec2f7df577bf
Version: webpack 1.13.3
Time: 853ms
Asset Size Chunks Chunk Names
server-bundle.js 24.5 kB 0 [emitted] main
-- server:watch bundled.
[14:53:35] Finished 'bundle' after 946 ms
[14:53:35] Starting 'start:server'...
Starting Node Server...
[14:53:36] Finished 'start:server' after 1.23 s
[14:53:36] Starting 'watch:sync'...
webpack built 7a9966082c49871875b8 in 386ms
Hash: 7a9966082c49871875b8
Version: webpack 1.13.3
Time: 386ms
Asset Size Chunks Chunk Names
main-bundle.js 99.3 kB 0 main
ERROR in ./src/client/index.js
Module parse failed: D:\Frontend-Master\src\client\index.js Unexpected token (64:2)
You may need an appropriate loader to handle this file type.
SyntaxError: Unexpected token (64:2)
at Parser.pp$4.raise (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:2221:15)
at Parser.pp.unexpected (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:603:10)
at Parser.pp$3.parseExprAtom (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1822:12)
at Parser.pp$3.parseExprSubscripts (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1715:21)
at Parser.pp$3.parseMaybeUnary (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1692:19)
at Parser.pp$3.parseExprOps (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1637:21)
at Parser.pp$3.parseMaybeConditional (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1620:21)
at Parser.pp$3.parseMaybeAssign (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1597:21)
at Parser.pp$3.parseExprList (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:2165:22)
at Parser.pp$3.parseSubscripts (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1741:35)
at Parser.pp$3.parseExprSubscripts (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1718:17)
at Parser.pp$3.parseMaybeUnary (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1692:19)
at Parser.pp$3.parseExprOps (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1637:21)
at Parser.pp$3.parseMaybeConditional (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1620:21)
at Parser.pp$3.parseMaybeAssign (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1597:21)
at Parser.pp$3.parseExpression (D:\Frontend-Master\node_modules\acorn\dist\acorn.js:1573:21)
# multi main
This is my index.js file
var debug = require('debug')('tes:client')
window.Promise = Promise;
window.$ = window.jQuery = $;
injectTapEventPlugin();
var browserHistory = useRouterHistory(createHistory)({
queryKey: false,
basename: '/'
});
var initialState = window.INITIAL_STATE || {};
var store = configureStore(initialState, browserHistory);
var routes = getRoutes(store);
var history = syncHistoryWithStore(browserHistory, store, {
selectLocationState: (state) => state.router
});
const ROOT_CONTAINER = document.getElementById('root');
const onRenderComplete = ()=> {
console.timeEnd('render');
}
if ( __DEV__ ){
window._STORE = store;
window.React = React;
window.ReactDOM = ReactDOM;
}
window.localStorage.debug = 'tessact:*'
window._History = history
let muiTheme = getMuiTheme(theme);
console.time('render');
match({ history, routes }, (error, redirectLocation, renderProps) => {
ReactDOM.render(
<MuiThemeProvider muiTheme={muiTheme}>
<Root store={store}>
<WithStylesContext onInsertCss={styles=> styles._insertCss()}>
<Router {...renderProps} />
</WithStylesContext>
</Root>
</MuiThemeProvider>,
ROOT_CONTAINER,
onRenderComplete
)
});
This is my client.config.js file
var path = require('path');
var webpack = require('webpack');
var DIRS = require('./dirs.js');
var stylus = require('stylus');
var nib = require('nib');
var axis = require('axis');
var rupture = require('rupture');
var bootstrap = require('bootstrap-styl');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
var IS_PROD = process.env.NODE_ENV === "production";
var config = {
devtool: IS_PROD ? false : 'eval',
debug: !IS_PROD,
cache: true,
root: DIRS.ROOT,
watchOptions: {
ignored: /node_modules/
},
entry: {
main: [ DIRS.SRC_CLIENT + '/index.js' ]
},
output: {
path: DIRS.BUILD_PUBLIC,
publicPath: '/public/',
filename: '[name]-bundle.js'
},
resolve: {
modulesDirectories: [ DIRS.SRC_CLIENT, 'node_modules'],
extensions: ['', '.webpack.js', '.web.js', '.js', '.styl'],
},
module: {
loaders: [
{test: /\.json$/, loader: 'json', exclude: /node_modules/},
{test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
include: [ DIRS.SRC_CLIENT ],
query: {
cacheDirectory: true,
env: {
development: {
presets: ['react-hmre']
}
}
}
},
{
test: /\.styl$/,
loader: [
'isomorphic-style-loader',
'css?sourceMap&localIdentName=[name]_[local]_[hash:base64:3]',
'stylus?sourceMap'
].join('!')
},
{
test: /\.css$/,
loader: 'style-loader!css-loader'
},
{
test: /\.woff(2)?(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'url-loader?limit=10000&mimetype=application/font-woff'
},
{
test: /\.(ttf|eot|svg)(\?v=[0-9]\.[0-9]\.[0-9])?$/,
loader: 'file-loader'
},{
test: /\.(png|jpg|jpeg|gif)$/,
loader: 'url-loader',
query: {
name: IS_PROD ? '[hash].[ext]' : '[path][name].[ext]?[hash]',
limit: 10000,
}
}
]
},
plugins: [
new webpack.DefinePlugin({
__DEV__: !IS_PROD,
__SERVER__: false,
"process.env.NODE_ENV": (IS_PROD ? JSON.stringify("production") : JSON.stringify("development"))
}),
new webpack.ProvidePlugin({
React: 'react'
}),
new webpack.ContextReplacementPlugin(/moment[\/\\]locale$/, /en/)
],
stylus: {
use: [nib(), axis(), rupture(), bootstrap()],
import: path.resolve(__dirname, '../src/stylus/index.styl'),
error: IS_PROD,
compress: IS_PROD,
'include css': true
}
};
if (IS_PROD){
// console.log('--- CLIENT:PRODUCTION_MODE ---');
config.entry.vendors = [
'react', 'react-dom', 'react-router',
'lodash', 'core-js', 'moment', 'jquery', 'bluebird',
'redux', 'react-redux', 'react-router-redux',
'history'
];
config.plugins = config.plugins.concat([
new webpack.optimize.CommonsChunkPlugin({
name: 'vendors',
filename: 'vendors-bundle.js'
}),
new webpack.optimize.UglifyJsPlugin({
compress: {warnings: false},
comments: false
}),
new webpack.optimize.AggressiveMergingPlugin(),
]);
} else {
config.entry.main.unshift('webpack-hot-middleware/client')
config.plugins = config.plugins.concat([
new webpack.DllReferencePlugin({
context: DIRS.SRC_CLIENT,
manifest: require(DIRS.BUILD_PUBLIC + '/dll/vendor-manifest.json')
}),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoErrorsPlugin()
]);
}
module.exports = config;
And this is scripts in package.json
"main": "index.js",
"scripts": {
"postinstall": "set NODE_ENV=production node -max_old_space_size=8192 ./node_modules/.bin/gulp build:prod",
"start": "node build/server-bundle.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
There is server.config.js file also which i haven't attached as think it is not necessary. Everything of this code works file in Ubuntu.
Error after Shubham Khatri's answer. I ran both the commands in comments of his answer.
> cross-env NODE_ENV=prod & node -max_old_space_size=8192 ./node_modules/.bin/gulp build:prod
D:\Frontend-Master\node_modules\.bin\gulp:2
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
^^^^^^^
SyntaxError: missing ) after argument list
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:509:3
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN tessact#0.0.1 No repository field.
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v6.9.1
npm ERR! npm v3.10.8
npm ERR! code ELIFECYCLE
npm ERR! tessact#0.0.1 postinstall: `cross-env NODE_ENV=prod & node -max_old_space_size=8192 ./node_modules/.bin/gulp build:prod`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tessact#0.0.1 postinstall script 'cross-env NODE_ENV=prod & node -max_old_space_size=8192 ./node_modules/.bin/gulp build:prod'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the tessact package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! cross-env NODE_ENV=prod & node -max_old_space_size=8192 ./node_modules/.bin/gulp build:prod
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs tessact
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls tessact
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! D:\Frontend-Master\npm-debug.log
Don't copy node modules as is, you are supposed to get all node modules again when you change OS.
Remove node_modules folder and run npm install.
BTW: importing node project with node_modules folder is not a good practice. you have to put node_modules in .gitignore
The way you have set NODE_ENV for postInstall doesn't work for windows but for linux.
For cross platform compatibility set NODE_ENV like cross-env NODE_ENV=prod &
So you package.json scripts looks like
"scripts": {
"postinstall": "cross-env NODE_ENV=prod & node -max_old_space_size=8192 ./node_modules/.bin/gulp build:prod",
"start": "node build/server-bundle.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
Also you can install the node_modules again with the npm install command when in windows.