vbenjs / vite-plugin-mock

A mock plugin for vite.use mockjs.
MIT License
621 stars 96 forks source link

[SSR] Cannot use import statement outside a module #68

Open kimmy-wang opened 2 years ago

kimmy-wang commented 2 years ago
/Users/ying/workspace/FEProjects/vue-vben-admin/node_modules/.pnpm/vite-plugin-mock@2.9.6_9cb7b45a435b0b365a3d11bf7a7969b0/node_modules/vite-plugin-mock/es/createProdMockServer.js:2
import mockJs from 'mockjs';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:1001:16)
    at Module._compile (internal/modules/cjs/loader.js:1049:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at Module.<anonymous> (/Users/ying/workspace/FEProjects/vue-vben-admin/dist/server/entry-server.js:67:28)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
/Users/ying/workspace/FEProjects/vue-vben-admin/node_modules/.pnpm/vite-plugin-mock@2.9.6_9cb7b45a435b0b365a3d11bf7a7969b0/node_modules/vite-plugin-mock/es/createProdMockServer.js:2
import mockJs from 'mockjs';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:1001:16)
    at Module._compile (internal/modules/cjs/loader.js:1049:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:101:18)
    at Module.<anonymous> (/Users/ying/workspace/FEProjects/vue-vben-admin/dist/server/entry-server.js:67:28)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
yangjindong commented 2 years ago

the same issue

LevineHua commented 2 years ago

me too