Vite使用Sass报错 Dep optimization failed with error ?

环境

win10
node v14.16.0
npm v6.14.11
vite 1.0.0-rc.13

步骤

$ npm init vite-app tmp
$ npm install
$ npm install sass
$ npm run dev

报错信息

[vite] Dep optimization failed with error:
Could not load readline (imported by node_modules\sass\sass.dart.js): ENOENT: no such file or directory, open 'D:\Code\NewIdea\tmp\tmp\readline'
[Error: Could not load readline (imported by node_modules\sass\sass.dart.js): ENOENT: no such file or directory, open 'D:\Code\NewIdea\tmp\tmp\readline'] {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'D:\\Code\\NewIdea\\tmp\\tmp\\readline',
  watchFiles: [
    'D:\\Code\\NewIdea\\tmp\\tmp\\node_modules\\sass\\sass.dart.js',
    '\x00commonjsHelpers.js',
    'D:\\Code\\NewIdea\\tmp\\tmp\\node_modules\\vue\\dist\\vue.runtime.esm-bundler.js',
    'D:\\Code\\NewIdea\\tmp\\tmp\\node_modules\\@vue\\runtime-dom\\dist\\runtime-dom.esm-bundler.js',
    'D:\\Code\\NewIdea\\tmp\\tmp\\node_modules\\@vue\\runtime-core\\dist\\runtime-core.esm-bundler.js',
    'D:\\Code\\NewIdea\\tmp\\tmp\\node_modules\\@vue\\shared\\dist\\shared.esm-bundler.js',
    'D:\\Code\\NewIdea\\tmp\\tmp\\node_modules\\@vue\\reactivity\\dist\\reactivity.esm-bundler.js',
    'readline',
    '\x00readline?commonjs-proxy',
    '\x00fs?commonjs-proxy',
    'fs'
  ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! tmp@0.0.0 dev: `vite`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the tmp@0.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

前几天是还能运行的,这两天就运行npm run dev就出错,不知道为什么

阅读 6.8k
1 个回答

npm install sass -D
sass装到devDependencies 下

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题
宣传栏