`no-unpublished-import`/`require` error importing devDependencies
See original GitHub issueI have private project:
package.json
(no files
field and no .npmignore
)
{
"name": "private-project",
"private": true,
"dependencies": {
"axios": "*"
},
"devDependencies": {
"@babel/core": "*"
}
When I load devDependencies, eslint throw an error:
index.js
import axios from 'axios';
import babel from '@babel/core'; // this throw an error: "@babel/core" is not published. eslint(node/no-unpublished-import)
// ...
with this following eslint configurations:
.eslintrc.js
module.export = {
settings: {
node: {
allowModules: [],
resolvePaths: [],
tryExtensions: ['.js', '.json', '.node'],
}
},
rules: {
'node/no-unpublished-import': 'error',
'node/no-unpublished-require': 'error',
}
}
But if I move babel in dependencies
, it does not throw an error
package.json
{
"name": "private-project",
"private": true,
"dependencies": {
"@babel/core": "*",
"axios": "*"
}
index.js
import axios from 'axios';
import babel from '@babel/core'; // this **does not** throw an error
// ...
Do I configure something wrong or is that expected behavior? Thanks.
More info: installed eslint version: 6.8.0 installed eslint-plugin-node version: 11.1.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
eslint-plugin-node/no-unpublished-import.md at master - GitHub
This is similar to no-unpublished-require, but this rule handles import declarations. ... imports *unpublished* files or the packages of devDependencies .
Read more >node/no-unpublished-import: "chai" is not published
The devDependencies option does not exist (anymore at leaast). If you want to allow imports from any package listed in your package.json, and ......
Read more >Managing dependencies - The Go Programming Language
After your code imports the package, enable dependency tracking and get the ... If needed, it adds require directives to your go.mod file...
Read more >package.json - npm Docs
This document is all you need to know about what's required in your package.json file. It must be actual JSON, not just a...
Read more >Inês Soares Silva (@inesoaresilva) / Twitter
#TIL how to allow imports from 'devDependencies'. In eslintrc file, add this rule: rules: { "node/no-unpublished-import": [ "error", { allowModules: [, ".
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
That’s the purpose of
no-unpublished-import
/require
rule. We cannot import thedevDependencies
after publishing the package.Awesome, thanks for clarifying, @latipun7 !