【解决】Cannot find module 'webpack'_npm

问题描述

配置webpack管理React,执行npm start报错

Error: Cannot find module ‘webpack’ 
at Function.Module._resolveFilename (module.js:326:15) 
at Function.Module._load (module.js:277:25) 
at Module.require (module.js:354:17) 
at require (internal/module.js:12:17) 
at Object. (/home/song/program/react_started/node_modules/webpack-dev-server/bin/webpack-dev-server.js:17:15) 
at Module._compile (module.js:410:26) 
at Object.Module._extensions..js (module.js:417:10) 
at Module.load (module.js:344:32) 
at Function.Module._load (module.js:301:12) 
at Function.Module.runMain (module.js:442:10) 尝试1

npm install webpack-dev-server -g

改为

npm install webpack-dev-server

其中 -g 参数表示全局安装 尝试2

将 webpack 作为本地依赖安装

npm i -D webpack

你可能感兴趣的:(vuejs)