-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate errors summary, Cannot find module 'pages_index.js?v=4759969c1da21941ddd6' from 'E:\XXX'. #3387
Comments
我也遇到这个问题~ 有好的办法解决吗 |
@shiyuegongsui 先安装一个 npm 的模块: npm install shelljs -D # OR yarn add shelljs -D 接着在项目下新建文件:
const { resolve } = require('path')
const fs = require('fs')
const SSRJSPath = resolve(__dirname, '../node_modules/vue-server-renderer/server-plugin.js')
const consola = require('consola')
const logProvider = consola.withScope('vue:patch')
module.exports = VueSSRPatch()
/**
* 对 `vue-server-renderer/server-plugin.js` 源码内容进行替换
* asset.name.match(/\.js$/)
* =>
* isJS(asset.name)
*/
function VueSSRPatch() {
//- 检测该模块是否存在
if (fs.existsSync(SSRJSPath)) {
let regexp = /asset\.name\.match\(\/\\\.js\$\/\)/
let SSRJSContent = fs.readFileSync(SSRJSPath, 'utf8')
//- 检测是否存在需要替换的内容(通常是指该项目在本机第一次运行)
if (regexp.test(SSRJSContent)) {
logProvider.start(`发现vue-server-renderer模块,开始执行修补操作!`)
SSRJSContent = SSRJSContent.replace(regexp, 'isJS(asset.name)')
fs.writeFileSync(SSRJSPath, SSRJSContent, 'utf8')
logProvider.ready(`修补完毕!`)
return true
}
logProvider.warn(`该模块已修补过,无需再次修补,可直接运行\`npm run dev\` 或 \`npm run gen\``)
return false
}
logProvider.warn(`未发现该模块,跳出本次修复!`)
return false
} 最后在 "scripts": {
"dev": "nuxt",
"generate": "nuxt generate",
"patch": "node build/vue-server-renderer.patch"
} patch:本机第一次运行或者更新相关模块(vue-server-renderer)时需要执行一次。 |
@songyazhao Thank you for so detailed investigation, I have opened a pull request. But I suggest that please use default value |
@clarkdo Hi I updated to Reproduction linkhttps://github.com/songyazhao/nuxt.js-issue3387__vue.js-issue8256/tree/nuxt@2.x I found the reason, I'll submit an |
Resolved with #4073 |
This bug-report has been fixed by @songyazhao. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Version
v1.4.0
Reproduction link
https://github.com/songyazhao/nuxt.js-issue3387__vue.js-issue8256
Steps to reproduce
Tips: My English is very poor, forgive me, The following part of the English description translation.
Reproduction Step
复现步骤
Step two
第二步
nuxt.config.js
Add the following configuration:nuxt.config.js
添加配置如下:Step three
第三步
Step four
第四步
An error is as follows:
呈现如下错误:
Bug tracking
Bug 追溯
nuxt.Js
the configuration above will generate relatedwebpack
configuration is as follows:nuxt.js
的上述配置会生成相关的webpack
配置如下:Locating the problem:
最终定位到问题:
Modified to:
修改为:
Can solve this problem, but I don't know his judgment changed here will not affect other places
可以解决这个问题,但是我不知道他这里的判断改了会不会对其他地方产生影响
What is expected ?
Compile successfully. No error.
What is actually happening?
Error: Cannot find module 'pages_index.js?v=4759969c1da21941ddd6' from 'E:\GitRepo-Other\vue-server-renderer-bug-mini-repo'
The text was updated successfully, but these errors were encountered: