Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Cannot find module 'node:path' #452

Closed
1 task
giusepetroso opened this issue Jul 20, 2022 · 8 comments
Closed
1 task

[Bug] Cannot find module 'node:path' #452

giusepetroso opened this issue Jul 20, 2022 · 8 comments
Labels
upstream This is an issue with another package

Comments

@giusepetroso
Copy link

giusepetroso commented Jul 20, 2022

What version of vite are you using?

^2.9.9

System info and storybook versions

System:
OS: Windows 10 10.0.22000
CPU: (16) x64 Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz
Binaries:
Node: 14.16.0 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.4 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.14.11 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: Spartan (44.22000.120.0), Chromium (103.0.1264.62)
npmPackages:
@storybook/addon-actions: ^6.5.9 => 6.5.9
@storybook/addon-essentials: ^6.5.9 => 6.5.9
@storybook/addon-interactions: ^6.5.9 => 6.5.9
@storybook/addon-links: ^6.5.9 => 6.5.9
@storybook/builder-vite: ^0.2.0 => 0.2.0
@storybook/testing-library: 0.0.13 => 0.0.13
@storybook/vue3: ^6.5.9 => 6.5.9

Describe the Bug

I installed storybook on a package project I am working on.

Just ran npx storybook init

Since the first run of npm run storybook there was this error:

$ npm run storybook

> bitboss-ui@0.0.1 storybook D:\Workspaces\MyProjects\test-storybook
> start-storybook -p 6006

info @storybook/vue3 v6.5.9
info 
ERR! Error: Cannot find module 'node:path'
ERR! Require stack:
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@vitejs\plugin-react\dist\index.cjs
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@storybook\builder-vite\dist\vite-config.js
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@storybook\builder-vite\dist\vite-server.js
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@storybook\builder-vite\dist\index.js
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@storybook\core-server\dist\cjs\utils\get-preview-builder.js
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@storybook\core-server\dist\cjs\build-static.js
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@storybook\core-server\dist\cjs\index.js
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@storybook\core\dist\cjs\server.js
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@storybook\core\server.js
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@storybook\vue3\dist\cjs\server\index.js
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@storybook\vue3\bin\index.js
ERR!     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
ERR!     at Function.Module._load (internal/modules/cjs/loader.js:725:27)
ERR!     at Module.require (internal/modules/cjs/loader.js:952:19)
ERR!     at require (internal/modules/cjs/helpers.js:88:18)
ERR!     at Object.<anonymous> (D:\Workspaces\MyProjects\test-storybook\node_modules\@vitejs\plugin-react\dist\index.cjs:3:14)
ERR!     at Module._compile (internal/modules/cjs/loader.js:1063:30)
ERR!     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
ERR!     at Module.load (internal/modules/cjs/loader.js:928:32)
ERR!     at Function.Module._load (internal/modules/cjs/loader.js:769:14)
ERR!     at Module.require (internal/modules/cjs/loader.js:952:19)
ERR!  Error: Cannot find module 'node:path'
ERR! Require stack:
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@vitejs\plugin-react\dist\index.cjs
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@storybook\builder-vite\dist\vite-config.js
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@storybook\builder-vite\dist\vite-server.js
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@storybook\builder-vite\dist\index.js
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@storybook\core-server\dist\cjs\utils\get-preview-builder.js
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@storybook\core-server\dist\cjs\build-static.js
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@storybook\core-server\dist\cjs\index.js
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@storybook\core\dist\cjs\server.js
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@storybook\core\server.js
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@storybook\vue3\dist\cjs\server\index.js
ERR! - D:\Workspaces\MyProjects\test-storybook\node_modules\@storybook\vue3\bin\index.js
ERR!     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
ERR!     at Function.Module._load (internal/modules/cjs/loader.js:725:27)
ERR!     at Module.require (internal/modules/cjs/loader.js:952:19)
ERR!     at require (internal/modules/cjs/helpers.js:88:18)
ERR!     at Object.<anonymous> (D:\Workspaces\MyProjects\test-storybook\node_modules\@vitejs\plugin-react\dist\index.cjs:3:14)
ERR!     at Module._compile (internal/modules/cjs/loader.js:1063:30)
ERR!     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
ERR!     at Module.load (internal/modules/cjs/loader.js:928:32)
ERR!     at Function.Module._load (internal/modules/cjs/loader.js:769:14)
ERR!     at Module.require (internal/modules/cjs/loader.js:952:19) {
ERR!   code: 'MODULE_NOT_FOUND',
ERR!   requireStack: [
ERR!     'D:\\Workspaces\\MyProjects\\test-storybook\\node_modules\\@vitejs\\plugin-react\\dist\\index.cjs',
ERR!     'D:\\Workspaces\\MyProjects\\test-storybook\\node_modules\\@storybook\\builder-vite\\dist\\vite-config.js',
ERR!     'D:\\Workspaces\\MyProjects\\test-storybook\\node_modules\\@storybook\\builder-vite\\dist\\vite-server.js',
ERR!     'D:\\Workspaces\\MyProjects\\test-storybook\\node_modules\\@storybook\\builder-vite\\dist\\index.js',
ERR!     'D:\\Workspaces\\MyProjects\\test-storybook\\node_modules\\@storybook\\core-server\\dist\\cjs\\utils\\get-preview-builder.js',
ERR!     'D:\\Workspaces\\MyProjects\\test-storybook\\node_modules\\@storybook\\core-server\\dist\\cjs\\build-static.js',
ERR!     'D:\\Workspaces\\MyProjects\\test-storybook\\node_modules\\@storybook\\core-server\\dist\\cjs\\index.js',
ERR!     'D:\\Workspaces\\MyProjects\\test-storybook\\node_modules\\@storybook\\core\\dist\\cjs\\server.js',
ERR!     'D:\\Workspaces\\MyProjects\\test-storybook\\node_modules\\@storybook\\core\\server.js',
ERR!     'D:\\Workspaces\\MyProjects\\test-storybook\\node_modules\\@storybook\\vue3\\dist\\cjs\\server\\index.js',
ERR!     'D:\\Workspaces\\MyProjects\\test-storybook\\node_modules\\@storybook\\vue3\\bin\\index.js'
ERR!   ]
ERR! }

WARN Broken build, fix the error above.
WARN You may need to refresh the browser.

info => Loading presets
√ Would you like to send crash reports to Storybook? ... yes

attention => Storybook now collects completely anonymous telemetry regarding usage.
This information is used to shape Storybook's roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://storybook.js.org/telemetry

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! bitboss-ui@0.0.1 storybook: `start-storybook -p 6006`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the bitboss-ui@0.0.1 storybook 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\gpetr\AppData\Roaming\npm-cache\_logs\2022-07-20T09_30_24_812Z-debug.log

Link to Minimal Reproducible Example

https://github.com/giusepetroso/test-storybook

Participation

  • I am willing to submit a pull request for this issue.
@giusepetroso giusepetroso added the bug Something isn't working label Jul 20, 2022
@IanVS IanVS added upstream This is an issue with another package and removed bug Something isn't working labels Jul 20, 2022
@IanVS
Copy link
Member

IanVS commented Jul 20, 2022

Hi, Vite 3 requires node 16 and above. See vitejs/vite#9113 for more details.

@IanVS IanVS closed this as not planned Won't fix, can't repro, duplicate, stale Jul 20, 2022
@IanVS
Copy link
Member

IanVS commented Jul 20, 2022

Oh, and if you're not using vite 3, please pin @storybook/builder-vite to 0.1.x instead, since 0.2.x requires vite 3.

@IanVS IanVS changed the title [Bug] [Bug] Cannot find module 'node:path' Jul 21, 2022
@giusepetroso
Copy link
Author

Thank you, it was the node version, I was using v14.16.0 (as in the system info).

@sourabh129
Copy link

You need to add "type": "module" in package.json to fix this in node v14

@IanVS
Copy link
Member

IanVS commented Sep 19, 2022

@sourabh129 that shouldn't have anything to do with this error. That has to do with how files named .js are treated, either as commonjs or as es modules.

@sourabh129
Copy link

@IanVS, You are right, but it somehow fixes the error. Please try adding it in this repo. Vite 3 works fine with node v14 when "type": "module" is present in package.json

@55Cancri
Copy link

55Cancri commented Nov 3, 2022

@sourabh129 is correct. Adding type: module does solve problem on node v14 but I'm not sure why

@Shenchuanhuan
Copy link

You need to add "type": "module" in package.json to fix this in node v14

it works for me. my node version is 14.15.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream This is an issue with another package
Projects
None yet
Development

No branches or pull requests

5 participants