I'm trying to use eslint-import-resolver-babel-module but without success. Airbnb config uses "node" resolver, and it seems that only it is used.
Here's my config:
{
"env": {
"browser": true
},
"extends": "airbnb",
"plugins": [
"react",
"jsx-a11y",
"import"
],
"rules": {
"no-param-reassign": [2, { "props": false }]
},
"parser": "babel-eslint",
"root": true,
"settings": {
"import/resolver": {
"babel-module": {}
}
}
}
I get compiled config using this:
$ ./node_modules/.bin/eslint --print-config src/test.js > eslintconfig 2>&1
Excerpt from the result:
...
"settings": {
"import/resolver": {
"node": {
"extensions": [
".js",
".jsx",
".json"
]
},
"babel-module": {}
},
...
Then I test using this command
$ cross-env DEBUG=eslint-plugin-import:resolver:* ./node_modules/.bin/eslint src/test.js > eslintdebug 2>&1
Output
Sun, 06 Aug 2017 14:16:33 GMT eslint-plugin-import:resolver:node Resolving: client/test2 from: D:XXX\src\test.js
Sun, 06 Aug 2017 14:16:33 GMT eslint-plugin-import:resolver:node resolve threw error: { Error: Cannot find module 'client/test2' from 'D:XXX\src'
at Function.module.exports [as sync] (D:XXX\node_modules\resolve\lib\sync.js:40:15)
at Object.exports.resolve (D:XXX\node_modules\eslint-import-resolver-node\index.js:18:28)
at v2 (D:XXX\node_modules\eslint-module-utils\resolve.js:79:23)
at withResolver (D:XXX\node_modules\eslint-module-utils\resolve.js:84:16)
at fullResolve (D:XXX\node_modules\eslint-module-utils\resolve.js:101:22)
at relative (D:XXX\node_modules\eslint-module-utils\resolve.js:46:10)
at resolve (D:XXX\node_modules\eslint-module-utils\resolve.js:172:12)
at checkSourceValue (D:XXX\node_modules\eslint-plugin-import\lib\rules\no-unresolved.js:29:50)
at checkSourceValue (D:XXX\node_modules\eslint-module-utils\moduleVisitor.js:29:5)
at EventEmitter.checkSource (D:XXX\node_modules\eslint-module-utils\moduleVisitor.js:34:5) code: 'MODULE_NOT_FOUND' }
Sun, 06 Aug 2017 14:16:33 GMT eslint-plugin-import:resolver:node Resolving: client/test2 from: D:XXX\src\test.js
Sun, 06 Aug 2017 14:16:33 GMT eslint-plugin-import:resolver:node resolve threw error: { Error: Cannot find module 'client/test2' from 'D:XXX\src'
at Function.module.exports [as sync] (D:XXX\node_modules\resolve\lib\sync.js:40:15)
at Object.exports.resolve (D:XXX\node_modules\eslint-import-resolver-node\index.js:18:28)
at v2 (D:XXX\node_modules\eslint-module-utils\resolve.js:79:23)
at withResolver (D:XXX\node_modules\eslint-module-utils\resolve.js:84:16)
at fullResolve (D:XXX\node_modules\eslint-module-utils\resolve.js:101:22)
at relative (D:XXX\node_modules\eslint-module-utils\resolve.js:46:10)
at resolve (D:XXX\node_modules\eslint-module-utils\resolve.js:172:12)
at resolveImportType (D:XXX\node_modules\eslint-plugin-import\lib\core\importType.js:74:65)
at reportIfMissing (D:XXX\node_modules\eslint-plugin-import\lib\rules\no-extraneous-dependencies.js:74:32)
at EventEmitter.ImportDeclaration (D:XXX\node_modules\eslint-plugin-import\lib\rules\no-extraneous-dependencies.js:144:9) code: 'MODULE_NOT_FOUND' }
Sun, 06 Aug 2017 14:16:33 GMT eslint-plugin-import:resolver:node Resolving: client/test2 from: D:XXX\src\test.js
Sun, 06 Aug 2017 14:16:33 GMT eslint-plugin-import:resolver:node resolve threw error: { Error: Cannot find module 'client/test2' from 'D:XXX\src'
at Function.module.exports [as sync] (D:XXX\node_modules\resolve\lib\sync.js:40:15)
at Object.exports.resolve (D:XXX\node_modules\eslint-import-resolver-node\index.js:18:28)
at v2 (D:XXX\node_modules\eslint-module-utils\resolve.js:79:23)
at withResolver (D:XXX\node_modules\eslint-module-utils\resolve.js:84:16)
at fullResolve (D:XXX\node_modules\eslint-module-utils\resolve.js:101:22)
at relative (D:XXX\node_modules\eslint-module-utils\resolve.js:46:10)
at resolve (D:XXX\node_modules\eslint-module-utils\resolve.js:172:12)
at EventEmitter.ImportDeclaration (D:XXX\node_modules\eslint-plugin-import\lib\rules\no-duplicates.js:37:52)
at emitOne (events.js:101:20)
at EventEmitter.emit (events.js:191:7) code: 'MODULE_NOT_FOUND' }
Sun, 06 Aug 2017 14:16:33 GMT eslint-plugin-import:resolver:node Resolving: client/test2 from: D:XXX\src\test.js
Sun, 06 Aug 2017 14:16:33 GMT eslint-plugin-import:resolver:node resolve threw error: { Error: Cannot find module 'client/test2' from 'D:XXX\src'
at Function.module.exports [as sync] (D:XXX\node_modules\resolve\lib\sync.js:40:15)
at Object.exports.resolve (D:XXX\node_modules\eslint-import-resolver-node\index.js:18:28)
at v2 (D:XXX\node_modules\eslint-module-utils\resolve.js:79:23)
at withResolver (D:XXX\node_modules\eslint-module-utils\resolve.js:84:16)
at fullResolve (D:XXX\node_modules\eslint-module-utils\resolve.js:101:22)
at relative (D:XXX\node_modules\eslint-module-utils\resolve.js:46:10)
at resolve (D:XXX\node_modules\eslint-module-utils\resolve.js:172:12)
at EventEmitter.checkFileExtension (D:XXX\node_modules\eslint-plugin-import\lib\rules\extensions.js:81:50)
at emitOne (events.js:101:20)
at EventEmitter.emit (events.js:191:7) code: 'MODULE_NOT_FOUND' }
Sun, 06 Aug 2017 14:16:33 GMT eslint-plugin-import:resolver:node Resolving: client/test2 from: D:XXX\src\test.js
Sun, 06 Aug 2017 14:16:33 GMT eslint-plugin-import:resolver:node resolve threw error: { Error: Cannot find module 'client/test2' from 'D:XXX\src'
at Function.module.exports [as sync] (D:XXX\node_modules\resolve\lib\sync.js:40:15)
at Object.exports.resolve (D:XXX\node_modules\eslint-import-resolver-node\index.js:18:28)
at v2 (D:XXX\node_modules\eslint-module-utils\resolve.js:79:23)
at withResolver (D:XXX\node_modules\eslint-module-utils\resolve.js:84:16)
at fullResolve (D:XXX\node_modules\eslint-module-utils\resolve.js:101:22)
at relative (D:XXX\node_modules\eslint-module-utils\resolve.js:46:10)
at resolve (D:XXX\node_modules\eslint-module-utils\resolve.js:172:12)
at Function.ExportMap.get (D:XXX\node_modules\eslint-plugin-import\lib\ExportMap.js:281:38)
at checkDefault (D:XXX\node_modules\eslint-plugin-import\lib\rules\no-named-as-default.js:25:41)
at emitOne (events.js:101:20) code: 'MODULE_NOT_FOUND' }
Sun, 06 Aug 2017 14:16:33 GMT eslint-plugin-import:resolver:node Resolving: client/test2 from: D:XXX\src\test.js
Sun, 06 Aug 2017 14:16:33 GMT eslint-plugin-import:resolver:node resolve threw error: { Error: Cannot find module 'client/test2' from 'D:XXX\src'
at Function.module.exports [as sync] (D:XXX\node_modules\resolve\lib\sync.js:40:15)
at Object.exports.resolve (D:XXX\node_modules\eslint-import-resolver-node\index.js:18:28)
at v2 (D:XXX\node_modules\eslint-module-utils\resolve.js:79:23)
at withResolver (D:XXX\node_modules\eslint-module-utils\resolve.js:84:16)
at fullResolve (D:XXX\node_modules\eslint-module-utils\resolve.js:101:22)
at relative (D:XXX\node_modules\eslint-module-utils\resolve.js:46:10)
at resolve (D:XXX\node_modules\eslint-module-utils\resolve.js:172:12)
at Function.ExportMap.get (D:XXX\node_modules\eslint-plugin-import\lib\ExportMap.js:281:38)
at EventEmitter.handleImportDefault (D:XXX\node_modules\eslint-plugin-import\lib\rules\no-named-as-default-member.js:35:45)
at emitOne (events.js:101:20) code: 'MODULE_NOT_FOUND' }
[4mD:XXX\src\test.js[24m
[2m1:1[22m [31merror[39m Resolve error: undefined [2mimport/no-unresolved[22m
[2m1:1[22m [31merror[39m Resolve error: undefined [2mimport/no-extraneous-dependencies[22m
[2m1:1[22m [31merror[39m 'client' should be listed in the project's dependencies. Run 'npm i -S client' to add it [2mimport/no-extraneous-dependencies[22m
[2m1:1[22m [31merror[39m Resolve error: undefined [2mimport/no-duplicates[22m
[2m1:1[22m [31merror[39m Resolve error: undefined [2mimport/extensions[22m
[2m1:1[22m [31merror[39m Resolve error: undefined [2mimport/no-named-as-default[22m
[2m1:1[22m [31merror[39m Resolve error: undefined [2mimport/no-named-as-default-member[22m
[2m1:8[22m [31merror[39m 'test' is defined but never used [2mno-unused-vars[22m
[2m1:18[22m [31merror[39m Unable to resolve path to module 'client/test2' [2mimport/no-unresolved[22m
[2m1:18[22m [31merror[39m Missing file extension for "client/test2" [2mimport/extensions[22m
[31m[1m✖ 10 problems (10 errors, 0 warnings)
[22m[39m
And here as you can see only eslint-plugin-import:resolver:node is used, no sight of eslint-plugin-import:resolver:babel-module.
I've also tried this:
"settings": {
"import/resolver": "babel-module"
}
But results are even worse:
[4mD:XXX\src\test.js[24m
[2m1:1[22m [31merror[39m Resolve error: undefined [2mimport/no-unresolved[22m
[2m1:1[22m [31merror[39m Resolve error: undefined [2mimport/no-extraneous-dependencies[22m
[2m1:1[22m [31merror[39m 'client' should be listed in the project's dependencies. Run 'npm i -S client' to add it [2mimport/no-extraneous-dependencies[22m
[2m1:1[22m [31merror[39m Resolve error: undefined [2mimport/no-duplicates[22m
[2m1:1[22m [31merror[39m Resolve error: undefined [2mimport/extensions[22m
[2m1:1[22m [31merror[39m Resolve error: undefined [2mimport/no-named-as-default[22m
[2m1:1[22m [31merror[39m Resolve error: undefined [2mimport/no-named-as-default-member[22m
[2m1:8[22m [31merror[39m 'test' is defined but never used [2mno-unused-vars[22m
[2m1:18[22m [31merror[39m Unable to resolve path to module 'client/test2' [2mimport/no-unresolved[22m
[2m1:18[22m [31merror[39m Missing file extension for "client/test2" [2mimport/extensions[22m
[31m[1m✖ 10 problems (10 errors, 0 warnings)
[22m[39m
Dependencies versions:
$ npm ls babel-plugin-module-resolver eslint-import-resolver-babel-module eslint-config-airbnb eslint-plugin-import eslint
house#0.1.0 D:\XXX
+-- babel-plugin-module-resolver#2.7.1
+-- eslint#3.19.0
+-- eslint-config-airbnb#15.0.2
+-- eslint-import-resolver-babel-module#3.0.0
`-- eslint-plugin-import#2.7.0
How to override plugin settings of parent config?
It turns out eslint-plugin-import takes a list of resolvers, and checks them one by one until one of them resolves the file correctly.
Related
I'm trying to probe a npm packet with node. The packet is this but when I'm doing the node script.js the following error appear on the console. This is what I'm trying to do:
import { get } from 'http'
import { http } from 'get-headers'
get('http://example.com', (res) => {
http(res) //=> { 'Accept-Ranges': 'bytes', 'Cache-Control': 'max-age=604800', 'Content-Type': 'text/html', Date: 'Mon, 17 Aug 2015 19:53:03 GMT', Etag: '"359670651"', Expires: 'Mon, 24 Aug 2015 19:53:03 GMT', 'Last-Modified': 'Fri, 09 Aug 2013 23:54:35 GMT', Server: 'ECS (rhv/818F)', 'X-Cache': 'HIT', 'x-ec-custom-error': '1', 'Content-Length': '1270', Connection: 'close' }
})
The error is the following:
(function (exports, require, module, __filename, __dirname) { import { get } from 'http';
^
SyntaxError: Unexpected token {
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 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
I've installed the two packages in the node_modules dir, I think that the mistake is because the interpreter doesn't understand the recent ecmascript and I've to do it whit the require but I've installed the latest version of node. Any idea of what could be happening?. Thank you
node --version 10:43
v11.10.1
UPDATE: I also tried to do it with the experimental flag but it yields this error.
ERROR
(node:12479) ExperimentalWarning: The ESM module loader is experimental.
/home/...:1
(function (exports, require, module, __filename, __dirname) { import { get } from 'http';
^
SyntaxError: Unexpected token {
at new Script (vm.js:85:7)
at createScript (vm.js:266:10)
at Proxy.runInThisContext (vm.js:314:10)
at Module._compile (internal/modules/cjs/loader.js:698:28)
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 createDynamicModule (internal/modules/esm/translators.js:78:15)
at Object.meta.done (internal/modules/esm/create_dynamic_module.js:40:9)
You are missing running the node app with the --experimental-modules flag enabled. Otherwise import is unknown for node you can see here a similar answer https://stackoverflow.com/a/54384132/4229159
Read here about import compatibility
I installed meanjs in my OpenSUSE distro, however when I run npm start, here's what I get:
+ Important warning: config.domain is empty. It should be set to the fully qualified domain of the app.
Unhandled rejection MongoError: not authorized on mean-dev to execute command { listIndexes: "sessions", cursor: {} }
at Function.MongoError.create (/home/tasher/Projects/meanjs_test/node_modules/mongodb-core/lib/error.js:31:11)
at queryCallback (/home/tasher/Projects/meanjs_test/node_modules/mongodb-core/lib/cursor.js:212:36)
at /home/tasher/Projects/meanjs_test/node_modules/mongodb-core/lib/connection/pool.js:469:18
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
From previous event:
at MongoStore.setAutoRemoveAsync (/home/tasher/Projects/meanjs_test/node_modules/connect-mongo/src/index.js:129:40)
at MongoStore.handleNewConnectionAsync (/home/tasher/Projects/meanjs_test/node_modules/connect-mongo/src/index.js:121:18)
at MongoStore (/home/tasher/Projects/meanjs_test/node_modules/connect-mongo/src/index.js:96:26)
at Object.module.exports.initSession (/home/tasher/Projects/meanjs_test/config/lib/express.js:120:12)
at Object.module.exports.init (/home/tasher/Projects/meanjs_test/config/lib/express.js:243:8)
at /home/tasher/Projects/meanjs_test/config/lib/app.js:25:23
at /home/tasher/Projects/meanjs_test/config/lib/mongoose.js:35:21
at process._tickCallback (internal/process/next_tick.js:109:7)
Unhandled rejection MongoError: not authorized on mean-dev to execute command { listIndexes: "sessions", cursor: {} }
at Function.MongoError.create (/home/tasher/Projects/meanjs_test/node_modules/mongodb-core/lib/error.js:31:11)
at queryCallback (/home/tasher/Projects/meanjs_test/node_modules/mongodb-core/lib/cursor.js:212:36)
at /home/tasher/Projects/meanjs_test/node_modules/mongodb-core/lib/connection/pool.js:469:18
at _combinedTickCallback (internal/process/next_tick.js:73:7)
at process._tickCallback (internal/process/next_tick.js:104:9)
From previous event:
at MongoStore.setAutoRemoveAsync (/home/tasher/Projects/meanjs_test/node_modules/connect-mongo/src/index.js:129:40)
at MongoStore.handleNewConnectionAsync (/home/tasher/Projects/meanjs_test/node_modules/connect-mongo/src/index.js:121:18)
at MongoStore (/home/tasher/Projects/meanjs_test/node_modules/connect-mongo/src/index.js:96:26)
at module.exports (/home/tasher/Projects/meanjs_test/config/lib/socket.io.js:73:20)
at Object.module.exports.configureSocketIO (/home/tasher/Projects/meanjs_test/config/lib/express.js:214:38)
at Object.module.exports.init (/home/tasher/Projects/meanjs_test/config/lib/express.js:258:14)
at /home/tasher/Projects/meanjs_test/config/lib/app.js:25:23
at /home/tasher/Projects/meanjs_test/config/lib/mongoose.js:35:21
at process._tickCallback (internal/process/next_tick.js:109:7)
error: uncaughtException: getaddrinfo ENOTFOUND linux-hcjz.suse date=Mon Aug 28 2017 22:46:50 GMT+0100 (WEST), pid=4497, uid=1000, gid=100, cwd=/home/tasher/Projects/meanjs_test, execPath=/usr/bin/node6, version=v6.11.1, argv=[/usr/bin/node6, /home/tasher/Projects/meanjs_test/server.js], rss=97284096, heapTotal=69029888, heapUsed=48863040, external=20182576, loadavg=[0.6513671875, 0.61669921875, 0.43505859375], uptime=3056
Error: getaddrinfo ENOTFOUND linux-hcjz.suse
at errnoException (dns.js:28:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
I have re-installed meanjs twice but in vain. Mongo is also running. By the way:
tasher#linux-hcjz:~/Projects/meanjs_test> node -v
v6.11.1
tasher#linux-hcjz:~/Projects/meanjs_test> npm6 -v
3.10.10
Any thoughts?
try adding execution permission to your mean-dev
chmod 755 path_for_package/mean-dev
replace path path_for_package with your path
I am working on an application which requires AWS (Amazon Web Services) push notification services.
I am running this on a node server, when I run the curl http request I get this error:
Registering user with deviceId: nodeserver
{ [Error: Missing credentials in config]
message: 'Missing credentials in config',
code: 'SigningError',
time: Tue Nov 17 2015 13:52:20 GMT+0000 (GMT),
originalError:
{ message: 'Could not load credentials from any providers',
code: 'CredentialsError',
time: Tue Nov 17 2015 13:52:20 GMT+0000 (GMT),
originalError:
{ message: 'Connection timed out after 1000ms',
code: 'TimeoutError',
time: Tue Nov 17 2015 13:52:20 GMT+0000 (GMT) } } }
Does anybody know what this error is or if anybody has had this type of error before and knows how to go about fixing it?
I have have an application running on heroku built with NodeJS
Application has Paypal integration with Paypal REST SDK
For some reason sometimes after calling the paypal sdk methods I getting error with "SELF_SIGNED_CERT_IN_CHAIN" message.
Also seems that this error is gone after the application is restarted.
The calling method is straight forward, which works without any issues 90% of time
// Bluebird promisified paypal.create function
// Payment object is usual paypal object descibed in Paypal NodeJS SDK samlpes
// https://github.com/paypal/PayPal-node-SDK/blob/master/samples/payment/create_with_paypal.js
paypal.payment.create(paymentObj)
.then(function(result) {
// handle result and redirect user to paypal confirm page
})
// Handle errors
.catch(function(err) {
log.error(err.stack);
res.status(500).json({
message: err.message
});
});
Here is the error stack
method=GET path="/api/v1/orders/create/1/multiple" request_id=ef4d2b98-7060-4049-9c72-13d58bd14184 status=500 bytes=246
Jun 04 04:39:17 app/web.2: problem with request: SELF_SIGNED_CERT_IN_CHAIN
Jun 04 04:39:17 app/web.2: {
Jun 04 04:39:17 app/web.2: "level": "error",
Jun 04 04:39:17 app/web.2: "message": " Error: SELF_SIGNED_CERT_IN_CHAIN\n at SecurePair.<anonymous> (tls.js:1381:32)\n at SecurePair.emit (events.js:92:17)\n at SecurePair.maybeInitFinished (tls.js:980:10)\n at CleartextStream.read [as _read] (tls.js:472:13)\n at CleartextStream.Readable.read (_stream_readable.js:341:10)\n at EncryptedStream.write [as _write] (tls.js:369:25)\n at doWrite (_stream_writable.js:226:10)\n at writeOrBuffer (_stream_writable.js:216:5)\n at EncryptedStream.Writable.write (_stream_writable.js:183:11)\n at write (_stream_readable.js:602:24)\n at flow (_stream_readable.js:611:7)\n at Socket.pipeOnReadable (_stream_readable.js:643:5)\n at Socket.emit (events.js:92:17)\n at emitReadable_ (_stream_readable.js:427:10)\n at emitReadable (_stream_readable.js:423:5)\n at readableAddChunk (_stream_readable.js:166:9)"
Jun 04 04:39:17 app/web.2: }
The SSL certificate is purchased through DNSimple and set up according this article
https://devcenter.heroku.com/articles/ssl-certificate-dnsimple
Any help or advice would be really appreciated.
Thanks
Gevorg
Error :
error: uncaughtException: connect ETIMEDOUT date=Wed Jan 14 2015
23:12:29 GMT+0530 (IST), pid=2397, uid=1000, gid=1000,
cwd=/home/user/node/workingcopy/server_dev, execPath=/usr/bin/nodejs,
version=v0.10.33,
argv=[nodejs, /home/user/node/workingcopy/server_dev/app.js], rss=69976064,
heapTotal=63359488, heapUsed=38560856, loadavg=[0.19091796875,
0.4814453125, 0.439453125], uptime=189505.245376888,
trace=[column=11, le=net.js, function=errnoException, line=904,
method=null,
native=false, column=19, file=net.js, function=Object.afterConnect [as
oncomplete], line=895, method=afterConnect [as oncomplete],
native=false], stack=[Error: connect ETIMEDOUT, at errnoException
(net.js:904:11), at Object.afterConnect [as oncomplete]
(net.js:895:19)]
How can we avoid server crash on this exception.?