2
respostas

Erro ao criar projeto no node.

Module not found: Error: Can't resolve 'web-vitals' in 'C:\Users\User1\organo\src' ERROR in ./src/reportWebVitals.js 5:4-24 Module not found: Error: Can't resolve 'web-vitals' in 'C:\Users\User1\organo\src'

webpack compiled with 1 error

2 respostas

C:\Users\User1\organo>npm start

organo@0.1.0 start react-scripts start

(node:3012) [DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE] DeprecationWarning: 'onAfterSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option. (Use node --trace-deprecation ... to show where the warning was created) (node:3012) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option. Starting the development server...

One of your dependencies, babel-preset-react-app, is importing the "@babel/plugin-proposal-private-property-in-object" package without declaring it in its dependencies. This is currently working because "@babel/plugin-proposal-private-property-in-object" is already in your node_modules folder for unrelated reasons, but it may break at any time.

babel-preset-react-app is part of the create-react-app project, which is not maintianed anymore. It is thus unlikely that this bug will ever be fixed. Add "@babel/plugin-proposal-private-property-in-object" to your devDependencies to work around this error. This will make this message go away. Failed to compile.

Module not found: Error: Can't resolve 'web-vitals' in 'C:\Users\1User1\organo\src' ERROR in ./src/reportWebVitals.js 5:4-24 Module not found: Error: Can't resolve 'web-vitals' in 'C:\Users\User1\organo\src'

webpack compiled with 1 error

E aí, Fabrício, tudo certo?

Esse "Module not found: Error: Can't resolve 'web-vitals'" tá indicando que o 'web-vitals' não tá sendo encontrado. Pra consertar, manda ver esse comando no terminal, na raiz do projeto:

npm install web-vitals

E confirma que o 'web-vitals' foi adicionado no 'package.json' como dependência.

Relaxa por enquanto com esses avisos de depreciação do Webpack Dev Server. São só alertas sobre opções antigas. Eles não afetam a execução do projeto.

Esse aviso sobre 'babel-preset-react-app' sugere adicionar "@babel/plugin-proposal-private-property-in-object" nas devDependencies pra evitar futuros pepinos. Roda esse comando no terminal:

npm install --save-dev @babel/plugin-proposal-private-property-in-object

E confirma que essa dependência tá listada no 'package.json' sob 'devDependencies'.

Sobre o projeto 'create-react-app' Esse aviso menciona que 'babel-preset-react-app' fazia parte do 'create-react-app', que agora tá meio abandonado. Isso quer dizer que, em projetos futuros, vale a pena pensar em outras configs do Babel, tipo o próprio 'babel-preset-react'.

Se der, pensa em migrar pra uma config manual do Babel, que dá mais flexibilidade e controle sobre as dependências.

"devDependencies": {
  "@babel/plugin-proposal-private-property-in-object": "^1.0.0",
  "web-vitals": "^1.0.0"
}

Ajusta as versões conforme precisar, porque elas podem mudar com o tempo.

Espero que isso te dê um empurrãozinho, bons estudos!

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software