BoltDoggy / parcel-plugin-vue

⚠️ parcel-bundler/parcel @1.7.0 support Vue Now. This plugin will be not recommended.
https://github.com/parcel-bundler/parcel
209 stars 15 forks source link

import local .js file in .vue file error #3

Closed areyouse7en closed 6 years ago

areyouse7en commented 6 years ago

write app.vue like this

import foo from './foo'
import './main.scss'

then got this error

parcel-demo.js:32 Uncaught Error: Cannot find module './foo'
BoltDoggy commented 6 years ago

@areyouse7en Thank you for this.

I published the 'parcel-plugin-vue@1.1.1'.

areyouse7en commented 6 years ago
⏳  Building...
Server running at http://localhost:1234
🚨  Cannot find module 'parcel-bundler/src/assets/JSAsset'
Error: Cannot find module 'parcel-bundler/src/packagers/JSPackager.js'
    at Function.Module._resolveFilename (module.js:527:15)
    at Function.Module._load (module.js:476:23)
    at Module.require (module.js:568:17)
    at require (C:\Users\seven\AppData\Local\Yarn\config\global\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
    at Object.<anonymous> (H:\practice\parcel-demo\node_modules\parcel-plugin-vue\src\VueAsset.js:3:17)
    at Module._compile (C:\Users\seven\AppData\Local\Yarn\config\global\node_modules\v8-compile-cache\v8-compile-cache.js:178:30)
    at Object.Module._extensions..js (module.js:635:10)
    at Module.load (module.js:545:32)
    at tryModuleLoad (module.js:508:12)
    at Function.Module._load (module.js:500:3)

Just use your example code. Anything else should I do?

BoltDoggy commented 6 years ago

@areyouse7en Are you installed the parcel-bundler?

You Should install parcel-bundler yourself

The plugins for parcel-bundler need a same version of parcel-bundler at runtime.

areyouse7en commented 6 years ago

我贴一下我的代码 default default default

现在运行以后报错 default

BoltDoggy commented 6 years ago

你直接给一个 repo 地址好了,我自己跑跑看 @areyouse7en

areyouse7en commented 6 years ago

https://github.com/areyouse7en/parcel-vue-demo

BoltDoggy commented 6 years ago

@areyouse7en 可能是 cache 机制有点问题,运行的时候使用下面这个命令是正常的

rm -rf dist && rm -rf .cache && parcel index.html

全局 parcel 可能和项目内 parcel 也可能会冲突,推荐在 package.json 添加 scripts

  "scripts": {
    "dev": "rm -rf .cache && rm -rf dist && parcel index.html"
  },

to run npm run dev instead of run rm -rf .cache && rm -rf dist && parcel index.html

from https://github.com/lc60005457/parcel-plugin-vue/issues/1

另外需要注意一个问题 https://github.com/parcel-bundler/parcel/issues/315

areyouse7en commented 6 years ago

确实是缓存的问题。