ERROR  Failed to compile with 1 errors                                                                                     12:48:43 PM

 error  in ./resources/assets/js/app.js

Module build failed: TypeError: Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.dirname (path.js:1324:5)
    at /home/vagrant/Code/pilishen-dev/node_modules/babel-core/lib/transformation/file/options/option-manager.js:353:36
    at /home/vagrant/Code/pilishen-dev/node_modules/babel-core/lib/transformation/file/options/option-manager.js:375:22
    at Array.map (native)
    at OptionManager.resolvePresets (/home/vagrant/Code/pilishen-dev/node_modules/babel-core/lib/transformation/file/options/option-manager.js:364:20)
    at OptionManager.mergePresets (/home/vagrant/Code/pilishen-dev/node_modules/babel-core/lib/transformation/file/options/option-manager.js:348:10)
    at OptionManager.mergeOptions (/home/vagrant/Code/pilishen-dev/node_modules/babel-core/lib/transformation/file/options/option-manager.js:307:14)
    at OptionManager.init (/home/vagrant/Code/pilishen-dev/node_modules/babel-core/lib/transformation/file/options/option-manager.js:465:10)

这个问题往往出现在你第一次运行npm run dev的时候,原因往往是npm install时安装的某些组件存在问题,当然大都也是版本不够新造成的。

这个时候,可能你会第一反应使用我们第二套课程里讲的npm rebuild命令,比如上面既然提示是babel-core这个组件的问题,那我们就应该npm rebuild babel-core

这样的思路是没问题的,不过npm rebuild这个命令,实际上是卸载了你已安装的那个组件,然后再重新装一遍,重装前后用的版本号都是一样的,而这里我们一般是需要安装相应组件的最新版本,因为Path must be a string.这个问题大都在相应组件的最新版本里更新解决了,所以这里其实直接npm install babel-core即可。

ERROR in ./src/app.js
Module build failed: TypeError: Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.extname (path.js:1429:5)
    at processText (/home/kingscott/newton/node_modules/standard/node_modules/eslint/lib/cli-engine.js:144:30)
    at CLIEngine.executeOnText (/home/kingscott/newton/node_modules/standard/node_modules/eslint/lib/cli-engine.js:671:26)
    at Linter.lintText (/home/kingscott/newton/node_modules/standard-engine/index.js:65:59)
    at Object.standardLoader (/home/kingscott/newton/node_modules/standard-loader/index.js:19:12)
 @ multi app

同样的,这里也是安装最新版本的standard组件即可。