Reactjs React.js get“获取”;找不到模块loadash.template“;错误
我使用Reactjs React.js get“获取”;找不到模块loadash.template“;错误,reactjs,Reactjs,我使用npx create react app myapp创建了一个react app,在运行npm start Error: Cannot find module 'lodash.template' Require stack: - C:\Desktop\react\myapp\node_modules\workbox-build\build\lib\populate-sw-template.js - C:\Desktop\react\myapp\node_modules\workbox
npx create react app myapp
创建了一个react app,在运行npm start
Error: Cannot find module 'lodash.template'
Require stack:
- C:\Desktop\react\myapp\node_modules\workbox-build\build\lib\populate-sw-template.js
- C:\Desktop\react\myapp\node_modules\workbox-webpack-plugin\build\generate-sw.js
- C:\Desktop\react\myapp\node_modules\workbox-webpack-plugin\build\index.js
- C:\\Desktop\react\myapp\node_modules\react-scripts\config\webpack.config.js
- C:\Desktop\react\myapp\node_modules\react-scripts\scripts\start.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\Users\vanst\OneDrive\Desktop\react\myapp\node_modules\workbox-build\build\lib\populate-sw-template.js:10:18)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19) {
code: 'MODULE_NOT_FOUND',
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myapp@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myapp@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\AppData\Roaming\npm-cache\_logs\2020-10-28T16_45_32_029Z-debug.log
错误:找不到模块“lodash.template”
需要堆栈:
-C:\Desktop\react\myapp\node\u modules\workbox build\build\lib\populate-sw-template.js
-C:\Desktop\react\myapp\node\u modules\workbox webpack plugin\build\generate-sw.js
-C:\Desktop\react\myapp\node\u modules\workbox webpack plugin\build\index.js
-C:\\Desktop\react\myapp\node\u modules\react scripts\config\webpack.config.js
-C:\Desktop\react\myapp\node\u modules\react scripts\scripts\start.js
位于Function.Module.\u解析文件名(internal/modules/cjs/loader.js:880:15)
at Function.Module._load(内部/modules/cjs/loader.js:725:27)
at Module.require(内部/modules/cjs/loader.js:952:19)
根据需要(内部/modules/cjs/helpers.js:88:18)
反对。(C:\Users\vanst\OneDrive\Desktop\react\myapp\node\u modules\workbox build\build\lib\populate sw template.js:10:18)
at模块编译(内部/modules/cjs/loader.js:1063:30)
在Object.Module._extensions..js(internal/modules/cjs/loader.js:1092:10)
在Module.load(内部/modules/cjs/loader.js:928:32)
at Function.Module._load(内部/modules/cjs/loader.js:769:14)
at Module.require(内部/modules/cjs/loader.js:952:19){
代码:“未找到模块”,
}
npm错误!代码失效循环
npm错误!错误1
npm错误!myapp@0.1.0开始:`react脚本开始`
npm错误!退出状态1
npm错误!
npm错误!失败myapp@0.1.0开始脚本。
npm错误!这可能不是npm的问题。上面可能还有其他日志输出。
npm错误!此运行的完整日志可在以下位置找到:
npm错误!C:\Users\AppData\Roaming\npm cache\\u logs\2020-10-28T16\u 45\u 32\u 029Z-debug.log
我可以通过运行npm install loadash--save来修复这个问题,但是我在网上找到的指令似乎可以很好地工作,没有这样做。我重新安装了node.js,这个错误再次出现,我想知道出了什么问题。尝试清除缓存:
npm cache clear --force
尝试清除缓存:
npm cache clear --force
在没有解释命令解决问题的方法(以及为什么需要强制)的情况下,建议使用--force
选项可能是不可取的。我不是说这不会解决问题,只是建议谨慎使用--force
。如果不解释命令解决问题的方法(以及为什么需要强制),建议使用--force
选项可能是不可取的。我并不是说这不会解决问题,只是建议谨慎使用--force
。