[英]Javascript Eslint Error: Cannot find module 'optionator'
We've got some error and we try to install optionator but nothing happened.我们遇到了一些错误,我们尝试安装 optionator 但没有任何反应。 We're using Linux
我们正在使用 Linux
We're trying to npm i
from package.json which include this dependencies我们正在尝试
npm i
来自 package.json 其中包括此依赖项
"optionalDependencies": {
"eslint-config-<name>": "github:<username>/<repo>"
}
then we tried to run npm i optionator
but still get the same error然后我们尝试运行
npm i optionator
但仍然出现相同的错误
Error: Cannot find module 'optionator'
Require stack:
- /usr/share/nodejs/eslint/lib/options.js
- /usr/share/nodejs/eslint/lib/cli.js
- /usr/share/nodejs/eslint/bin/eslint.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:885:15)
at Function.Module._load (internal/modules/cjs/loader.js:730:27)
at Module.require (internal/modules/cjs/loader.js:957:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/usr/share/nodejs/eslint/lib/options.js:12:20)
at Module._compile (internal/modules/cjs/loader.js:1068:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:933:32)
at Function.Module._load (internal/modules/cjs/loader.js:774:14)
at Module.require (internal/modules/cjs/loader.js:957:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/share/nodejs/eslint/lib/options.js',
'/usr/share/nodejs/eslint/lib/cli.js',
'/usr/share/nodejs/eslint/bin/eslint.js'
Anyone who experienced this, please help us.任何经历过这种情况的人,请帮助我们。 Thanks
谢谢
So if you have not done an npm init then that is the issue.因此,如果您还没有完成 npm 初始化,那么这就是问题所在。
npm init
initializes the project and will add the node_modules
folder to the working directory, this will set it up as a node project. npm init
初始化项目并将node_modules
文件夹添加到工作目录,这会将其设置为节点项目。 Then to install a dependency just run a npm install <dependency>
although I do recommend doing a --save
afterwards as well as it just ensures that the package is put in your current directory然后安装依赖项只需运行
npm install <dependency>
尽管我确实建议之后执行--save
以及它只是确保 package 放在您的当前目录中
$ npm init
$ npm install optionator --save
Need to give full access to package-lock.json需要完全访问 package-lock.json
Nothing worked until when I initialized the project in a new directory and reinstalled all the dependent modules afresh.直到我在新目录中初始化项目并重新安装所有依赖模块之前,没有任何效果。
If you are using linux do this如果您使用的是 linux,请执行此操作
sudo eslint init
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.