欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

vue项目npm run dev报错

程序员文章站 2022-05-13 19:34:28
...

使用cnpm install也不行。

 ERROR  Failed to compile with 1 errors                                                                                                                                                                           11:16:55
 error  in ./src/App.vue

Module build failed: Error: ENOENT: no such file or directory, scandir 'E:\BaiduNetdiskDownload\mmm20190430\node_modules\node-sass\vendor'
    at Object.readdirSync (fs.js:785:3)
    at Object.getInstalledBinaries (E:\BaiduNetdiskDownload\mmm20190430\node_modules\node-sass\lib\extensions.js:130:13)
    at foundBinariesList (E:\BaiduNetdiskDownload\mmm20190430\node_modules\node-sass\lib\errors.js:20:15)
    at foundBinaries (E:\BaiduNetdiskDownload\mmm20190430\node_modules\node-sass\lib\errors.js:15:5)
    at Object.module.exports.missingBinary (E:\BaiduNetdiskDownload\mmm20190430\node_modules\node-sass\lib\errors.js:45:5)
    at module.exports (E:\BaiduNetdiskDownload\mmm20190430\node_modules\node-sass\lib\binding.js:15:30)
    at Object.<anonymous> (E:\BaiduNetdiskDownload\mmm20190430\node_modules\node-sass\lib\index.js:14:35)
    at Module._compile (internal/modules/cjs/loader.js:701:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10)
    at Module.load (internal/modules/cjs/loader.js:600:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:539:12)
    at Function.Module._load (internal/modules/cjs/loader.js:531:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.sassLoader (E:\BaiduNetdiskDownload\mmm20190430\node_modules\sass-loader\lib\loader.js:46:72)

 @ ./node_modules/vue-style-loader!./node_modules/css-loader?{"sourceMap":true}!./node_modules/vue-loader/lib/style-compiler?{"vue":true,"id":"data-v-7ba5bd90","scoped":false,"hasInlineConfig":false}!./node_modules/sass-loader/lib/loader.js?{"sourceMap":true}!./node_modules/vue-loader/lib/selector.js?type=styles&index=0!./src/App.vue 4:14-359 13:3-17:5 14:22-367
 @ ./src/App.vue
 @ ./src/main.js
 @ multi (webpack)-dev-server/client?http://0.0.0.0:8098 webpack/hot/dev-server babel-polyfill ./src/main.js

执行cnpm install node-sass --save;之后,再执行npm run dev终于成功了。

1、cnpm install
2、cnpm install sass-loader --save;
3、cnpm install node-sass --save;
4、cnpm install babel-polyfill --save-dev  //解决浏览器对es6语法的支持
5、cnpm install es6-promise --save-dev //解决浏览器对es6语法的支持
6、npm run dev

注1:浏览器对es6语法的支持需修改webpack.base.conf.js:
module.exports = {
  context: path.resolve(__dirname, '../'),
  entry: {
    app: ['babel-polyfill', './src/main.js'],/* 用这个代替下面的 */
        /*entry: {
    app: './src/main.js'
        },*/
  },
注2:浏览器对es6语法的支持需修改main.js增加:
import 'babel-polyfill';
import promise from 'es6-promise';
promise.polyfill();