我已经有同样的 eslint 问题好几天了。
团队中的每个人都拥有相同的 eslintrc 和已安装的 eslint 版本。他们的 eslint 工作正常,我的不行。
我尝试重新启动我的计算机,删除 node_modules,删除我的用户下的任何内容(在主目录中)。什么都行不通。
问题:
./node_modules/.bin/eslint *.js*
? 1 ? ? 11504 ? 10:19:47
Cannot read property 'range' of null
TypeError: Cannot read property 'range' of null
at SourceCode.getTokenBefore (/Users/jhill/gitRepo/sponsoroo/node_modules/eslint/lib/token-store/index.js:303:18)
at checkSpacingBefore (/Users/jhill/gitRepo/sponsoroo/node_modules/eslint/lib/rules/template-curly-spacing.js:52:42)
at TemplateElement (/Users/jhill/gitRepo/sponsoroo/node_modules/eslint/lib/rules/template-curly-spacing.js:117:17)
at listeners.(anonymous function).forEach.listener (/Users/jhill/gitRepo/sponsoroo/node_modules/eslint/lib/util/safe-emitter.js:47:58)
at Array.forEach (<anonymous>)
at Object.emit (/Users/jhill/gitRepo/sponsoroo/node_modules/eslint/lib/util/safe-emitter.js:47:38)
at NodeEventGenerator.applySelector (/Users/jhill/gitRepo/sponsoroo/node_modules/eslint/lib/util/node-event-generator.js:251:26)
at NodeEventGenerator.applySelectors (/Users/jhill/gitRepo/sponsoroo/node_modules/eslint/lib/util/node-event-generator.js:280:22)
at NodeEventGenerator.enterNode (/Users/jhill/gitRepo/sponsoroo/node_modules/eslint/lib/util/node-event-generator.js:294:14)
at CodePathAnalyzer.enterNode (/Users/jhill/gitRepo/sponsoroo/node_modules/eslint/lib/code-path-analysis/code-path-analyzer.js:608:23)
Run Code Online (Sandbox Code Playgroud)
细节
版本:
./node_modules/.bin/eslint --version
v4.16.0
Run Code Online (Sandbox Code Playgroud)
.eslintrc
{
"extends": ["airbnb-base", "plugin:security/recommended"],
"rules": {
"import/prefer-default-export": "off", …Run Code Online (Sandbox Code Playgroud) 希望能够components直接从目录导入目录中的任何组件components。
当前的目录结构是:
\nsrc\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 components\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Camera.tsx\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Keyboard.tsx\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 index.ts\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 screens\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 App.tsx\nRun Code Online (Sandbox Code Playgroud)\n并希望能够按如下方式导入:
\nsrc\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 components\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Camera.tsx\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 Keyboard.tsx\n\xe2\x94\x82 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 index.ts\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 screens\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 App.tsx\nRun Code Online (Sandbox Code Playgroud)\n第一个选择显然是维护一长串导出列表src/components/index.ts:
// src/screens/App.tsx\n\nimport { Keyboard } from \'../components\'\nRun Code Online (Sandbox Code Playgroud)\n然而,这维护起来很麻烦。有没有一种方法使用glob导出对象来自动导出所有组件,或者可能有另一种方式一起导出?
我正在尝试使用 JavaScript 模块执行以下代码。我知道 NodeJS 默认是 CommonJS。我的代码在本地工作,但是当我想将其作为 lambda 中的模块运行时,我遇到了以下问题:
错误:
{
"errorType": "ReferenceError",
"errorMessage": "exports is not defined in ES module scope\nThis file is being treated as an ES module because it has a '.js' file extension and '/var/task/package.json' contains \"type\": \"module\". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.",
"trace": [
"ReferenceError: exports is not defined in ES module scope",
"This file is being treated as an ES module because it has a …Run Code Online (Sandbox Code Playgroud) 我尝试更新,我尝试.idea从项目中删除文件夹.我甚至从Windows中的用户/用户删除了我的整个设置文件夹.最后一个有所帮助,但我不得不导入我的旧设置,对我来说改变一切都有太大的改变,问题再次出现.
索引时,PhpStorm会显示该node_modules文件夹.完成后,文件夹消失.我没有设置范围,我没有排除该文件夹.
我按照这个问题PhpStorm隐藏了项目窗口中的目录,它没有帮助.
如果我node_modules从目录设置中设置为源文件夹,然后从项目视图中选择"项目文件",那么只有这样我才能在sidenav中看到它...这让我疯狂......
我在执行时遇到以下错误npm install:
$ npm install
npm ERR! code 127
npm ERR! path /home/jesusjimenez/projects/project/node_modules/fibers
npm ERR! command failed
npm ERR! command sh -c node build.js || nodejs build.js
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@15.12.0 | linux | x64
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Command failed: /usr/bin/python3 -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! …Run Code Online (Sandbox Code Playgroud) 我有一个my-parser-generator使用pegjs的私有 GitHub 存储库。所有底层逻辑都用 TypeScript 编写,然后编译并输入到pegjs,生成最终的解析器。
然后这个 repo a 被用作另一个私有 repo 中的包依赖项parser-consumer,它是用 TypeScript 编写的(使用--declaration选项编译)。所以my-parser-generator基本上是向 TypeScript 使用者提供 JavaScript 文件。
但是当我尝试导入新生成的解析器时,出现以下错误:
TS2307: Cannot find module 'my-parser-generator' or its corresponding type declarations
我已经尝试了互联网上的大部分解决方案,但没有一个对我有用
package.json(省略了大部分行)
{
"private": true,
"version": "0.4.9",
"name": "my-parser-generator",
"files": [
"dist/lib/**/*.js",
"dist/excel.browser.js",
"dist/**/*.d.ts",
"dist/**/*.js.map"
],
"main": "dist/excel.browser.js",
"typings": "dist/index.d.ts",
"type": "module",
"dependencies": {
"pegjs": "^0.11.0-master.b7b87ea"
}
}
Run Code Online (Sandbox Code Playgroud)
tsconfig.json
{
"compilerOptions": {
"target": "es2019",
"allowJs": true,
"skipLibCheck": true, …Run Code Online (Sandbox Code Playgroud) 公开节点包模块的标准方法是将它们列在index.ts中,如下所示:
export * from './module1';
export * from './module2';
Run Code Online (Sandbox Code Playgroud)
但是,这会立即加载两个模块的内容。我想要一个未在 index.ts 文件中导出的模块,因为它需要安装一些可选的依赖项。
我遵循了本指南:https://blog.mozilla.org/data/2021/04/07/this-week-in-glean-publishing-glean-js/
我的package.json:
"exports": {
".": {
"import": "./dist/es/index.js",
"require": "./dist/cjs/index.js"
},
"./module2": {
"import": "./dist/es/module2.js",
"require": "./dist/cjs/module2.js"
}
},
"typesVersions": {
"*": {
".": [
"./dist/types/index.d.ts"
],
"./module2": [
"./dist/types/module2.d.ts"
]
}
},
// fallback for older Node versions:
"module": "dist/es/index.js",
"main": "dist/cjs/index.js",
"types": "dist/types/index.d.ts",
Run Code Online (Sandbox Code Playgroud)
在我构建项目后(使用tsc,分别用于 CJS 和 ESM),输出目录结构如下所示:
- dist
- cjs
- index.js
- module2.js
- es
- index.js
- module2.js
- types …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用纱线安装包,但我不断收到“找不到模块”错误。当我尝试使用此文件夹中的纱线运行任何命令时,它会出现此错误。值得注意的是,在我删除 .yarn 文件夹后,错误开始发生。
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module '/home/chronos/user/Downloads/codes/some-react-app/.yarn/releases/yarn-3.1.1.cjs'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Run Code Online (Sandbox Code Playgroud)
我应该删除我的yarn.lock 文件,或者我能做些什么来解决这个问题。
如何恢复节点模块和bower_components?
一点上下文:我打算只控制实际上属于我的应用程序而不是依赖项的文件.我想要的是在克隆项目的新副本后恢复这些依赖项.我想要的是类似于bower wiredep的反转.
这个标题可能有点误导,但请耐心等待一段时间.
我Angular2在2015年的visual studio上制作了一个简单的应用程序,现在我已经有了published it on Azure.
在开发环境中使用node_modules是完美的,但在部署之后显示错误,说无法找到node_modules.
以下是我在index.html的开发环境中引用的方法-
<!-- Polyfill(s) for older browsers -->
<script src="/node_modules/core-js/client/shim.min.js"></script>
<script src="/node_modules/zone.js/dist/zone.js"></script>
<script src="/node_modules/reflect-metadata/Reflect.js"></script>
<script src="/node_modules/systemjs/dist/system.src.js"></script>
<script src="/systemjs.config.js"></script>
Run Code Online (Sandbox Code Playgroud)
它也在system.config.js中引用-
/**
* System configuration for Angular 2 samples
* Adjust as necessary for your application needs.
*/
(function(global) {
// map tells the System loader where to look for things
var map = {
'app': '/app', // 'dist',
'@angular': '/node_modules/@angular',
'angular2-in-memory-web-api': '/node_modules/angular2-in-memory-web-api',
'rxjs': '/node_modules/rxjs'
};
// packages …Run Code Online (Sandbox Code Playgroud) node-modules ×10
typescript ×4
node.js ×3
npm ×2
angular ×1
aws-lambda ×1
azure ×1
bower ×1
commonjs ×1
deployment ×1
es6-modules ×1
eslint ×1
github ×1
javascript ×1
json ×1
node-gyp ×1
npm-install ×1
pegjs ×1
phpstorm ×1
react-native ×1
reactjs ×1
yarnpkg ×1