i have an error at nodejs with 'oracledb' - javascript

I have an error with oracledb modules.
I have successed to install oracledb.
when i typed like this,
-> npm install oracledb
njsOracle.cpp
njsPool.cpp
njsConnection.cpp
njsResultSet.cpp
njsMessages.cpp
njsIntLob.cpp
dpiEnv.cpp
dpiEnvImpl.cpp
dpiException.cpp
dpiExceptionImpl.cpp
dpiConnImpl.cpp
dpiDateTimeArrayImpl.cpp
dpiPoolImpl.cpp
dpiStmtImpl.cpp
dpiUtils.cpp
dpiLob.cpp
dpiCommon.cpp
win_delay_load_hook.cc
C:\Users\aaa\AppData\Roaming\npm\node_modules\oracledb\build\Release\oracledb.lib 라이브러리 및 C:\Users\aaa
\AppData\Roaming\npm\node_modules\oracledb\build\Release\oracledb.exp 개체를 생성하고 있습니다.
코드를 생성하고 있습니다.
코드를 생성했습니다.
oracledb.vcxproj -> C:\Users\aaa\AppData\Roaming\npm\node_modules\oracledb\build\Release\oracledb.node
oracledb.vcxproj -> C:\Users\aaa\AppData\Roaming\npm\node_modules\oracledb\build\Release\oracledb.pdb (Full PDB)
C:\Users\GwiTtaeGi\AppData\Roaming\npm
`-- oracledb#1.13.1
but when i execute require('oracledb'), there's an error like this.
Error: The specified procedure could not be found.
\?\c:\testnode\test\node_modules\oracledb\build\Release\oracledb.node
at Error (native)
at Object.Module._extensions..node (module.js:597:18)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (c:\testnode\test\node_modules\oracledb\lib\oracledb.js:35:19)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
I can't fix this error..
version is..
node -v : v6.10.3
npm -v : 4.5.0

Firstly, try to clean NPM cache
rm -rf ~/.node-gyp ~/.npm; npm cache clean
If error still occurs, try set NODE_PATH environment variable

Related

Can't run require('opencv4nodejs')

I'm using macOS Monterey 12.2.1, Apple M1. And in the project directory, I installed opencv-build and opencv4nodejs by this script code:
"scripts": { "postinstall": "npm i opencv-build && npm i opencv4nodejs" }
When I run cv = require('opencv4nodejs'), I got this error message and I can't understand it. How can I run this code correctly?
/usr/local/bin/node /Users/david/Desktop/project2/main.js
/Users/david/Desktop/project2/node_modules/opencv4nodejs/lib/cv.js:47
throw err
^
Error: Cannot find module '/Users/david/Desktop/project2/node_modules/opencv4nodejs/build/Release/opencv4nodejs'
Require stack:
- /Users/david/Desktop/project2/node_modules/opencv4nodejs/lib/cv.js
- /Users/david/Desktop/project2/node_modules/opencv4nodejs/lib/opencv4nodejs.js
- /Users/david/Desktop/project2/main.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/Users/david/Desktop/project2/node_modules/opencv4nodejs/lib/cv.js:40:8)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/david/Desktop/project2/node_modules/opencv4nodejs/lib/cv.js',
'/Users/david/Desktop/project2/node_modules/opencv4nodejs/lib/opencv4nodejs.js',
'/Users/david/Desktop/project2/main.js'
]
}
Process finished with exit code 1
Use Node 14.18.1, then uninstall opencv4nodejs.
Run export CXXFLAGS="-std=c++14 -Wno-c++11-narrowing"
Run npm install opencv4nodejs

npx react-native init MainApp Giving error (code: 'MODULE_NOT_FOUND',) . What's the isue here

I got this error while running the above command (npx react-native init MainApp)
I have installed the latest version of node and npm. I am not sure why this error is reflected.
Tried clearing the cache changing the node version to 17 but no luck. I am new to this react native.
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module './error'
Require stack:
- C:\Users\priye\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#hapi\hoek\lib\assert.js
- C:\Users\priye\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#hapi\topo\lib\index.js
- C:\Users\priye\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\node_modules\joi\lib\types\keys.js
- C:\Users\priye\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\node_modules\joi\lib\types\function.js
- C:\Users\priye\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\node_modules\joi\lib\index.js
- C:\Users\priye\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\tools\config\schema.js
- C:\Users\priye\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\tools\config\readConfigFromDisk.js
- C:\Users\priye\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\tools\config\index.js
- C:\Users\priye\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\commands\install\install.js
- C:\Users\priye\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\commands\index.js
- C:\Users\priye\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\index.js
- C:\Users\priye\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#react-native-community\cli\build\bin.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\priye\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\#hapi\hoek\lib\assert.js:3:21)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\priye\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#hapi\\hoek\\lib\\assert.js',
'C:\\Users\\priye\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#hapi\\topo\\lib\\index.js',
'C:\\Users\\priye\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\node_modules\\joi\\lib\\types\\keys.js',
'C:\\Users\\priye\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\node_modules\\joi\\lib\\types\\function.js',
'C:\\Users\\priye\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\node_modules\\joi\\lib\\index.js',
'C:\\Users\\priye\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\build\\tools\\config\\schema.js',
'C:\\Users\\priye\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\build\\tools\\config\\readConfigFromDisk.js',
'C:\\Users\\priye\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\build\\tools\\config\\index.js',
'C:\\Users\\priye\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\build\\commands\\install\\install.js',
'C:\\Users\\priye\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\build\\commands\\index.js',
'C:\\Users\\priye\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\build\\index.js',
'C:\\Users\\priye\\AppData\\Local\\npm-cache\\_npx\\7930a8670f922cdb\\node_modules\\#react-native-community\\cli\\build\\bin.js'
]
}
Hi I myself resolved the issue. I deleted the npm-cache folder from the AppData folder and it worked :). Thanks

Mocha 6, Babel 7, ES6: SyntaxError: Unexpected token export

I'm trying to create a simple npm package based on another called 'sidebar-v2' (https://github.com/Turbo87/sidebar-v2)
For that reason, I've tried to update the JS code to ES6, however when I try to test if the updates are ok, the mocha raises an exception, that I send below:
> #rmmariano/ol-sb#1.0.0-rc.1 test /home/inpe/Documents/datainfo/npm_packages/ol-sb
> mocha --require #babel/register
/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/ol/control.js:5
export {default as Attribution} from './control/Attribution.js';
^^^^^^
SyntaxError: Unexpected token export
at new Script (vm.js:85:7)
at createScript (vm.js:266:10)
at Object.runInThisContext (vm.js:314:10)
at Module._compile (internal/modules/cjs/loader.js:698:28)
at Module._compile (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/pirates/lib/index.js:99:24)
at Module._extensions..js (internal/modules/cjs/loader.js:749:10)
at Object.newLoader [as .js] (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/pirates/lib/index.js:104:7)
at Module.load (internal/modules/cjs/loader.js:630:32)
at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
at Function.Module._load (internal/modules/cjs/loader.js:562:3)
at Module.require (internal/modules/cjs/loader.js:667:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/home/inpe/Documents/datainfo/npm_packages/ol-sb/src/ol3-sidebar.js:1:1)
at Module._compile (internal/modules/cjs/loader.js:738:30)
at Module._compile (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/pirates/lib/index.js:99:24)
at Module._extensions..js (internal/modules/cjs/loader.js:749:10)
at Object.newLoader [as .js] (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/pirates/lib/index.js:104:7)
at Module.load (internal/modules/cjs/loader.js:630:32)
at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
at Function.Module._load (internal/modules/cjs/loader.js:562:3)
at Module.require (internal/modules/cjs/loader.js:667:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/home/inpe/Documents/datainfo/npm_packages/ol-sb/src/index.js:1:1)
at Module._compile (internal/modules/cjs/loader.js:738:30)
at Module._compile (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/pirates/lib/index.js:99:24)
at Module._extensions..js (internal/modules/cjs/loader.js:749:10)
at Object.newLoader [as .js] (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/pirates/lib/index.js:104:7)
at Module.load (internal/modules/cjs/loader.js:630:32)
at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
at Function.Module._load (internal/modules/cjs/loader.js:562:3)
at Module.require (internal/modules/cjs/loader.js:667:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/home/inpe/Documents/datainfo/npm_packages/ol-sb/test/test.js:4:1)
at Module._compile (internal/modules/cjs/loader.js:738:30)
at Module._compile (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/pirates/lib/index.js:99:24)
at Module._extensions..js (internal/modules/cjs/loader.js:749:10)
at Object.newLoader [as .js] (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/pirates/lib/index.js:104:7)
at Module.load (internal/modules/cjs/loader.js:630:32)
at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
at Function.Module._load (internal/modules/cjs/loader.js:562:3)
at Module.require (internal/modules/cjs/loader.js:667:17)
at require (internal/modules/cjs/helpers.js:20:18)
at /home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/lib/mocha.js:327:36
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/lib/mocha.js:324:14)
at Mocha.run (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/lib/mocha.js:801:10)
at Object.exports.singleRun (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/lib/cli/run-helpers.js:207:16)
at exports.runMocha (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/lib/cli/run-helpers.js:300:13)
at Object.exports.handler.argv [as handler] (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/lib/cli/run.js:296:3)
at Object.runCommand (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/yargs/lib/command.js:238:44)
at Object.parseArgs [as _parseArgs] (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/yargs/yargs.js:1089:24)
at Object.parse (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/yargs/yargs.js:566:25)
at Object.exports.main (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/lib/cli/cli.js:62:6)
at Object.<anonymous> (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/bin/_mocha:10:23)
at Module._compile (internal/modules/cjs/loader.js:738:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10)
at Module.load (internal/modules/cjs/loader.js:630:32)
at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
at Function.Module._load (internal/modules/cjs/loader.js:562:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:801:12)
at internal/main/run_main_module.js:21:11
npm ERR! Test failed. See above for more details.
I've already tried to follow the answer of other questions on StackOverflow, such as:
Babel unexpected token import when running mocha tests
Unexpected token import, can not set up ES6 in my JS project with Mocha, Chai and Sinon
But no one of them worked to me, unfortunately.
When I try to update my .babelrc to:
{
"presets": ["#babel/preset-env", "es2015"]
}
The error changes to:
> #rmmariano/ol-sb#1.0.0-rc.1 test /home/inpe/Documents/datainfo/npm_packages/ol-sb
> mocha --require #babel/register
/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/yargs/yargs.js:1148
else throw err
^
Error: Cannot find module 'babel-preset-es2015' from '/home/inpe/Documents/datainfo/npm_packages/ol-sb'
at Function.module.exports [as sync] (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/resolve/lib/sync.js:58:15)
at resolveStandardizedName (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/files/plugins.js:101:31)
at resolvePreset (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/files/plugins.js:58:10)
at loadPreset (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/files/plugins.js:77:20)
at createDescriptor (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/config-descriptors.js:154:9)
at items.map (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/config-descriptors.js:109:50)
at Array.map (<anonymous>)
at createDescriptors (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/config-descriptors.js:109:29)
at createPresetDescriptors (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/config-descriptors.js:101:10)
at presets (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/config-descriptors.js:47:19)
at mergeChainOpts (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/config-chain.js:320:26)
at /home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/config-chain.js:283:7
at buildRootChain (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/config-chain.js:120:22)
at loadPrivatePartialConfig (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/partial.js:85:55)
at loadFullConfig (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/full.js:43:39)
at loadOptions (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/index.js:27:36)
at OptionManager.init (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/index.js:231:36)
at compile (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/register/lib/node.js:61:42)
at compileHook (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/register/lib/node.js:102:12)
at Module._compile (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/pirates/lib/index.js:93:29)
at Module._extensions..js (internal/modules/cjs/loader.js:749:10)
at Object.newLoader [as .js] (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/pirates/lib/index.js:104:7)
at Module.load (internal/modules/cjs/loader.js:630:32)
at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
at Function.Module._load (internal/modules/cjs/loader.js:562:3)
at Module.require (internal/modules/cjs/loader.js:667:17)
at require (internal/modules/cjs/helpers.js:20:18)
at /home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/lib/mocha.js:327:36
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/lib/mocha.js:324:14)
at Mocha.run (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/lib/mocha.js:801:10)
at Object.exports.singleRun (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/lib/cli/run-helpers.js:207:16)
at exports.runMocha (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/lib/cli/run-helpers.js:300:13)
at Object.exports.handler.argv [as handler] (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/lib/cli/run.js:296:3)
at Object.runCommand (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/yargs/lib/command.js:238:44)
at Object.parseArgs [as _parseArgs] (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/yargs/yargs.js:1089:24)
at Object.parse (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/yargs/yargs.js:566:25)
at Object.exports.main (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/lib/cli/cli.js:62:6)
at Object.<anonymous> (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/bin/_mocha:10:23)
at Module._compile (internal/modules/cjs/loader.js:738:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10)
at Module.load (internal/modules/cjs/loader.js:630:32)
at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
at Function.Module._load (internal/modules/cjs/loader.js:562:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:801:12)
at internal/main/run_main_module.js:21:11
npm ERR! Test failed. See above for more details.
package.json
{
...
"scripts": {
"start": "nodemon --exec babel-node ./src/index.js",
"test": "./node_modules/.bin/mocha --require #babel/register"
},
"devDependencies": {
"#babel/cli": "^7.2.3",
"#babel/core": "^7.3.4",
"#babel/node": "^7.2.2",
"#babel/preset-env": "^7.3.4",
"#babel/register": "^7.0.0",
"chai": "^4.2.0",
"mocha": "^6.0.2",
"nodemon": "^1.18.10"
},
"dependencies": {
"ol": "^5.3.1"
}
}
.babelrc
{
"presets": ["#babel/preset-env"]
}
Could someone help me?
Source code can be found here: https://github.com/rmmariano/ol-sb
Edit 1:
I've tried to update my .babelrc to:
{
"presets": ["#babel/preset-env", "es2015"]
}
And to install the package:
npm install -S babel-preset-es2015
But the following error starts to appear when I run "npm test":
> #rmmariano/ol-sb#1.0.0-rc.1 test /home/inpe/Documents/datainfo/npm_packages/ol-sb
> mocha --require #babel/register
/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/yargs/yargs.js:1148
else throw err
^
Error: Plugin/Preset files are not allowed to export objects, only functions. In /home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/babel-preset-es2015/lib/index.js
at createDescriptor (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/config-descriptors.js:178:11)
at items.map (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/config-descriptors.js:109:50)
at Array.map (<anonymous>)
at createDescriptors (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/config-descriptors.js:109:29)
at createPresetDescriptors (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/config-descriptors.js:101:10)
at presets (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/config-descriptors.js:47:19)
at mergeChainOpts (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/config-chain.js:320:26)
at /home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/config-chain.js:283:7
at buildRootChain (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/config-chain.js:120:22)
at loadPrivatePartialConfig (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/partial.js:85:55)
at loadFullConfig (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/full.js:43:39)
at loadOptions (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/config/index.js:27:36)
at OptionManager.init (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/core/lib/index.js:231:36)
at compile (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/register/lib/node.js:61:42)
at compileHook (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/#babel/register/lib/node.js:102:12)
at Module._compile (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/pirates/lib/index.js:93:29)
at Module._extensions..js (internal/modules/cjs/loader.js:749:10)
at Object.newLoader [as .js] (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/pirates/lib/index.js:104:7)
at Module.load (internal/modules/cjs/loader.js:630:32)
at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
at Function.Module._load (internal/modules/cjs/loader.js:562:3)
at Module.require (internal/modules/cjs/loader.js:667:17)
at require (internal/modules/cjs/helpers.js:20:18)
at /home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/lib/mocha.js:327:36
at Array.forEach (<anonymous>)
at Mocha.loadFiles (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/lib/mocha.js:324:14)
at Mocha.run (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/lib/mocha.js:801:10)
at Object.exports.singleRun (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/lib/cli/run-helpers.js:207:16)
at exports.runMocha (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/lib/cli/run-helpers.js:300:13)
at Object.exports.handler.argv [as handler] (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/lib/cli/run.js:296:3)
at Object.runCommand (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/yargs/lib/command.js:238:44)
at Object.parseArgs [as _parseArgs] (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/yargs/yargs.js:1089:24)
at Object.parse (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/yargs/yargs.js:566:25)
at Object.exports.main (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/lib/cli/cli.js:62:6)
at Object.<anonymous> (/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/mocha/bin/_mocha:10:23)
at Module._compile (internal/modules/cjs/loader.js:738:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10)
at Module.load (internal/modules/cjs/loader.js:630:32)
at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
at Function.Module._load (internal/modules/cjs/loader.js:562:3)
at Function.Module.runMain (internal/modules/cjs/loader.js:801:12)
at internal/main/run_main_module.js:21:11
npm ERR! Test failed. See above for more details.
Edit 2:
I've tried to update my .babelrc to:
{
"presets": ["#babel/preset-env", "#babel/preset-es2015"]
}
And to install the package:
npm install -S #babel/preset-es2015
But the following error starts to appear when I run "npm test":
> #rmmariano/ol-sb#1.0.0-rc.1 test /home/inpe/Documents/datainfo/npm_packages/ol-sb
> mocha --require #babel/register
/home/inpe/Documents/datainfo/npm_packages/ol-sb/node_modules/yargs/yargs.js:1148
else throw err
^
Error: Cannot find module '#babel/preset-es2015' from '/home/inpe/Documents/datainfo/npm_packages/ol-sb'
Short solution. I had a similar problem with imports and exports.
Also, Babel did not work well with mocha version 7.2.0 and npm version 6.14.4. So I solved the problem using esm version 3.2.25.
npm install --save-dev esm
My package.json is using this:
"scripts": {
"test": "mocha -r esm --exit"
}
I was searching through the whole internet to find a solution. I came up with this:
npx mocha --require ts-node/register --require esm src/**/*.spec.ts
Or in package.json scripts (both options work, choose whichever you like):
"scripts": {
"test": "mocha -r esm -r ts-node/register src/**/*.spec.ts",
"test-ts": "ts-mocha -r esm -p tsconfig.json src/**/*.spec.ts"
}
And don't forget to add esm to devDependencies:
npm install --save-dev esm
so in package.json it is gonna be
"devDependencies": {
"esm": "^3.2.25"
}
I get your code on github, and I see your problem.
This problem is in your ol3-sidebar.js, in this file on first line you import a function from file ol/control.js, but this file is not present in your workspace. So it is giving error when running the tests.
I had the same problem. And managed to solve it after re-installing windows and it still not working.
For me it was that the project folder was on a different drive accessed via a symbolic link. I have a small SSD for boot so keep project folders on a second larger disk drive, and symlink from my home directory to this folder.
If i navigate directly to the folder it works.
I'll report this to both Mocha and Babel teams. I'm not sure who's problem this is.
I think your problem(s) come from Babel. Try first:
npx babel-upgrade
to see the modifications that the package babel-upgrade will do without applying them, and if your are satisfied:
npx babel-upgrade --write
to apply the modifications.
I had a similar problem and had to run
npm install --save-dev core-js#3
My .bablerc was:
{
"presets": [["#babel/preset-env"]]
}

'Blob is not defined' error in async-array-buffer. How to fix it?

I'm getting error when trying start SSR and import { AudioContext } from standardized-audio-context
/workspace/node_modules/async-array-buffer/build/es5/bundle.js:10
var blob = new Blob([worker], {
^
ReferenceError: Blob is not defined
at /workspace/node_modules/async-array-buffer/build/es5/bundle.js:10:13
at /workspace/node_modules/async-array-buffer/build/es5/bundle.js:2:65
at Object.<anonymous> (/workspace/node_modules/async-array-buffer/build/es5/bundle.js:5:2)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Module._compile (/workspace/node_modules/pirates/lib/index.js:83:24)
at Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Object.newLoader [as .js] (/workspace/node_modules/pirates/lib/index.js:88:7)
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)
error Command failed with exit code 1.
How to possible to fix and where i need start to dig?
First of all, install the below package
-> npm install blob-polyfill
After that go to server.ts file, make an import and add blob to global.
-> import { Blob } from 'blob-polyfill'
-> global['Blob'] = Blob
I guess now you are all set to go.

Babel JS babel-preset-php error

I was just trying the new Babel's babel-preset-php (https://gitlab.com/kornelski/babel-preset-php#php7-to-es7-syntax-translator). I did everything in the README file, I installed the preset with npm i -S babel-preset-php. Then I created a .babelrc file with the following contents;
{
"presets": ["php"]
}
Installed the cli with npm i -g babel-cli. Then I created a simple PHP file that only contains a simple function:
<?php
function addCalculator($x, $y)
{
return $x + $y;
}
And tried to run the transpiler with babel number.php -o file.js. But I get an error in the execution of the script:
/home/claudio/Documents/Development/babel/node_modules/babel-preset-php/lib/plugins.js:6
Identifier(p) {
^
SyntaxError: Unexpected token ( (While processing preset: "/home/claudio/Documents/Development/babel/node_modules/babel-preset-php/index.js")
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/home/claudio/Documents/Development/babel/node_modules/babel-preset-php/index.js:1:79)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
I'm not that experient with nodejs and npm, so any idea on what might be happening?
Edit: Ok, I just realized that you are calling a public function outside of a class. That's not correct PHP. You can't define a function as public outside of a class. Your PHP code is just wrong.
The error is being emitted before it even touches your PHP code. It is, in fact, erroring on this particular line of babel-preset-php itself:
return {
visitor: {
Identifier(p) { // This is the invalid line
if (p.node.name != 'Exception' || p.scope.hasBinding("Exception")) {
return;
}
This preset is using the shorthand object initializers added in ECMAScript 2015. What is probably happening here is that your local Javascript environment does not support ES2015 syntax.
I would recommend updating node and babel to the latest versions and trying again.

Categories