Javascript 应用程序找不到已安装的软件包
我已经安装并使用了Javascript 应用程序找不到已安装的软件包,javascript,node.js,reactjs,npm,package.json,Javascript,Node.js,Reactjs,Npm,Package.json,我已经安装并使用了npm-install-formik和npm-install-yup 它们出现在依赖项对象的package.json中 在我的文件中,它们的导入方式如下: import * as Yup from 'yup'; import { Formik, Form, Field } from 'formik'; 但当我运行npm start时,我收到以下错误消息: 第3:22行:无法解析模块“yup”导入的路径/没有未解析的路径 第5:37行:无法解析模块“formik”导入的路径/没
npm-install-formik
和npm-install-yup
它们出现在依赖项对象的package.json中
在我的文件中,它们的导入方式如下:
import * as Yup from 'yup';
import { Formik, Form, Field } from 'formik';
但当我运行npm start
时,我收到以下错误消息:
第3:22行:无法解析模块“yup”导入的路径/没有未解析的路径
第5:37行:无法解析模块“formik”导入的路径/没有未解析的路径
这是什么原因?也许这与埃斯林有关
我的ESLintr:
{
"extends": [
"airbnb",
"react-app",
"prettier",
"prettier/flowtype",
"prettier/react"
],
"rules": {
// Allow jsx tags inside .js files.
"react/jsx-filename-extension": [1, {"extensions": [".js", ".jsx"]}],
// Disable props spreading (<App {...props} />) warning.
"react/jsx-props-no-spreading": 1,
// Throw warning instead of error when using array index as a key.
"react/no-array-index-key": 1,
// Disable react prop-types validation
"react/prop-types": 0,
// Allow modules with named exports only.
"import/prefer-default-export": 0,
// Throw warning instead of error. Feel free to choose your favorite option https://eslint.org/docs/rules/arrow-body-style
"arrow-body-style": ["warn", "as-needed"],
// Make prettier code formatting suggestions more verbose.
"prettier/prettier": ["warn"],
// Throw warning when <a href="#"> or <a href="javascript:void(0)"> are used. Use <button> instead.
"jsx-a11y/anchor-is-valid": ["warn", {"aspects": ["invalidHref"]}],
// Allow using (props) => <Component /> and ({propName}) => <Component /> syntax.
"react/destructuring-assignment": "off",
// Disable <Fragment> => <> replacement. Feel free to change
"react/jsx-fragments": "off",
// Below is the set of functional rules to warn developer about accidental mutations, which may cause error in reducers etc.
// No delete operator.
"fp/no-delete": "warn",
// Warning when Object.assign(a, b) used, since it mutates first argument. Object.assign({}, a, b) is ok.
"fp/no-mutating-assign": "warn",
"no-underscore-dangle": 0,
"import/no-extraneous-dependencies": ["error", {"devDependencies": true}]
},
"plugins": ["prettier", "fp"],
"settings": {
"import/resolver": {
"node": {
"moduleDirectory": ["node_modules", "./src"]
}
}
}
}
如果包正确就位,请参见
ls node_modules/{yup,formik}
如果是这样,请尝试重新启动react服务器。
如果没有,请使用
npm install
(如果它已经在package.json
中)重新安装。如果包正确就位,请参阅ls node_modules/{yup,formik}
如果是这样,请尝试重新启动react服务器。
如果没有,请使用
npm install
(如果它已经在package.json
中)重新安装。您是否检查了这些软件包是否正确安装?如何检查?我假设如果它们出现在package.json中,它们的安装是正确的。您检查过这些包是否正确安装了吗?我如何检查?我假设,如果它们出现在package.json中,那么它们的安装是正确的。我用package.json和eslintrc文件更新了我的问题,可能是与它们相关的东西,但它仍然不起作用。我用package.json和eslintrc文件更新了我的问题,可能与它们有关