yntaxError: Invalid or unexpected token

E:\js\code\vue.js\day01\4\code\04_begin_vue_devserver>npm run dev

> @ dev E:\js\code\vue.js\day01\4\code\04_begin_vue_devserver
> ..\node_modules\.bin\webpack-dev-server --inline --hot --open

E:\js\code\vue.js\day01\4\code\node_modules\uuid\v4.js:1
(function (exports, require, module, __filename, __dirname) {


SyntaxError: Invalid or unexpected token
    at new Script (vm.js:85:7)
    at createScript (vm.js:266:10)
    at Object.runInThisContext (vm.js:314:10)
    at Module._compile (internal/modules/cjs/loader.js:698:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:749:10)
    at Module.load (internal/modules/cjs/loader.js:630:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:570:12)
    at Function.Module._load (internal/modules/cjs/loader.js:562:3)
    at Module.require (internal/modules/cjs/loader.js:667:17)
    at require (internal/modules/cjs/helpers.js:20:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `..\node_modules\.bin\webpack-dev-server --inline --hot --open`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to in
stall?

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Program Files\nodejs\node_cache\_logs\2019-03-31T02_49_55_323Z-d
ebug.log

主要是因为node_modules文件有问题,E:\js\code\vue.js\day01\4\code\node_modules\uuid\v4.js:1打开全是0000,好像是因为格式不是UTF-8

SyntaxError: Invalid or unexpected token是因为 数据有特殊字符;数据有特殊字符;数据有特殊字符;

錯誤如上可能是JS文本的文件格式不對,如果保存的是Unicode就會出現如上的錯誤,可以從新建一個UTF-8或者ANSI格式的

格式错误

我又重新复制了一个好的node_modules文件,如果运行缺模块就npm install就好了

Logo

前往低代码交流专区

更多推荐