Error: Cannot find module 'recast'
original001 opened this issue · 6 comments
npm -v 5.6-5.8
node -v 8.9.4
you have recast
in devDependencies, but you are using this module in general file. In some case I don't get module on top of node_modules
tree. and it doesn't exist in node_modules
of babel-plugin-react-docgen
. it only exist in react-docgen
node_modules
. Please, add recast in dependencies.
I get this too
$ npm run storybook
> surge-staffing-manager@0.1.0 storybook /Users/gmauer/code/surge-ops_dev/repos/apps/staffing-manager
> start-storybook -p 9009 -s public
info @storybook/react v4.1.4
info
info => Loading static files from: /Users/gmauer/code/surge-ops_dev/repos/apps/staffing-manager/public .
info => Loading presets
info => Loading presets
info => Loading custom addons config.
info => Loading create-react-app config.
info => Using default webpack setup based on "create-react-app".
info => Loading create-react-app config.
webpack built ae32ffbd4355d1715147 in 11085ms
✖ 「wdm」: Hash: ae32ffbd4355d1715147
Version: webpack 4.28.3
Time: 11085ms
Built at: 01/04/2019 10:39:49 PM
Asset Size Chunks Chunk Names
iframe.html 2.25 KiB [emitted]
main.ae32ffbd4355d1715147.bundle.js 3.25 KiB main [emitted] main
main.ae32ffbd4355d1715147.bundle.js.map 130 bytes main [emitted] main
runtime~main.ae32ffbd4355d1715147.bundle.js 31 KiB runtime~main [emitted] runtime~main
runtime~main.ae32ffbd4355d1715147.bundle.js.map 32.1 KiB runtime~main [emitted] runtime~main
vendors~main.ae32ffbd4355d1715147.bundle.js 553 KiB vendors~main [emitted] [big] vendors~main
vendors~main.ae32ffbd4355d1715147.bundle.js.map 562 KiB vendors~main [emitted] vendors~main
Entrypoint main [big] = runtime~main.ae32ffbd4355d1715147.bundle.js runtime~main.ae32ffbd4355d1715147.bundle.js.map vendors~main.ae32ffbd4355d1715147.bundle.js vendors~main.ae32ffbd4355d1715147.bundle.js.map main.ae32ffbd4355d1715147.bundle.js main.ae32ffbd4355d1715147.bundle.js.map
[0] multi ./node_modules/@storybook/core/dist/server/common/polyfills.js ./node_modules/@storybook/core/dist/server/preview/globals.js ./.storybook/config.js ./node_modules/webpack-hot-middleware/client.js?reload=true 64 bytes {main} [built]
[./.storybook/config.js] 1.32 KiB {main} [built] [failed] [1 error]
[./node_modules/@storybook/core/dist/server/common/polyfills.js] 114 bytes {vendors~main} [built]
[./node_modules/@storybook/core/dist/server/preview/globals.js] 93 bytes {vendors~main} [built]
[./node_modules/@storybook/core/node_modules/core-js/fn/symbol/index.js] 240 bytes {vendors~main} [built]
[./node_modules/@storybook/core/node_modules/core-js/modules/_core.js] 122 bytes {vendors~main} [built]
[./node_modules/@storybook/core/node_modules/webpack/buildin/module.js] (webpack)/buildin/module.js 497 bytes {vendors~main} [built]
[./node_modules/airbnb-js-shims/index.js] 40 bytes {vendors~main} [built]
[./node_modules/global/window.js] 232 bytes {vendors~main} [built]
[./node_modules/querystring-es3/index.js] 127 bytes {vendors~main} [built]
[./node_modules/regenerator-runtime/runtime.js] 23 KiB {vendors~main} [built]
[./node_modules/strip-ansi/index.js] 161 bytes {vendors~main} [built]
[./node_modules/webpack-hot-middleware/client-overlay.js] 2.16 KiB {vendors~main} [built]
[./node_modules/webpack-hot-middleware/client.js?reload=true] 7.59 KiB {vendors~main} [built]
[./node_modules/webpack-hot-middleware/process-update.js] 4.26 KiB {vendors~main} [built]
+ 155 hidden modules
ERROR in ./.storybook/config.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Cannot find module 'recast'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/Users/gmauer/code/surge-ops_dev/repos/apps/staffing-manager/node_modules/babel-plugin-react-docgen/lib/actualNameHandler.js:10:38)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
at Function.Module._load (internal/modules/cjs/loader.js:530:3)
at Module.require (internal/modules/cjs/loader.js:637:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/Users/gmauer/code/surge-ops_dev/repos/apps/staffing-manager/node_modules/babel-plugin-react-docgen/lib/index.js:16:49)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
at Module.load (internal/modules/cjs/loader.js:599:32)
@ multi ./node_modules/@storybook/core/dist/server/common/polyfills.js ./node_modules/@storybook/core/dist/server/preview/globals.js ./.storybook/config.js ./node_modules/webpack-hot-middleware/client.js?reload=true main[2]
Child HtmlWebpackCompiler:
Asset Size Chunks Chunk Names
__child-HtmlWebpackPlugin_0 559 KiB HtmlWebpackPlugin_0 HtmlWebpackPlugin_0
Entrypoint HtmlWebpackPlugin_0 = __child-HtmlWebpackPlugin_0
[./node_modules/@storybook/core/node_modules/html-webpack-plugin/lib/loader.js!./node_modules/@storybook/core/dist/server/templates/index.ejs] 1.75 KiB {HtmlWebpackPlugin_0} [built]
[./node_modules/@storybook/core/node_modules/webpack/buildin/global.js] (webpack)/buildin/global.js 472 bytes {HtmlWebpackPlugin_0} [built]
[./node_modules/@storybook/core/node_modules/webpack/buildin/module.js] (webpack)/buildin/module.js 497 bytes {HtmlWebpackPlugin_0} [built]
[./node_modules/lodash/lodash.js] 527 KiB {HtmlWebpackPlugin_0} [built]
then it just spins
The fix would be to move it from devDependencies to dependencies
deleting all node_modules and storybook and reinstalling them and npx
init'ing storybook worked for me to fix it...so maybe it's not on yall and just a result of the npm ecosystem getting absurdly complex lately?
I don't know...
It sometimes works depending on the hoisting of the package manager and what other packages are installed, but relying on this hoisting is a bad practice and can lead to unexpected results.
This also breaks use of yarn Plug'n'Play, or if you use yarn's nohoist feature to prevent recast
from a different transitive dependency from being moved to node_modules/recast
This is broken in pnpm too. It just needs to be added to dependencies.
fixed in version 2.0.2