mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
fix(cli): prefer require dependencies from local node_modules (#4337)
This commit is contained in:
parent
c9459e7aa9
commit
992849ee1a
@ -1,4 +1,19 @@
|
|||||||
export const builder = () => import('@nuxt/builder')
|
import path from 'path'
|
||||||
export const webpack = () => import('@nuxt/webpack')
|
|
||||||
export const generator = () => import('@nuxt/generator')
|
const localNodeModules = path.resolve(process.cwd(), 'node_modules')
|
||||||
export const core = () => import('@nuxt/core')
|
|
||||||
|
// Prefer importing modules from local node_modules (for NPX and global bin)
|
||||||
|
async function _import(modulePath) {
|
||||||
|
let m
|
||||||
|
try {
|
||||||
|
m = await import(path.resolve(localNodeModules, modulePath))
|
||||||
|
} catch (e) {
|
||||||
|
m = await import(modulePath)
|
||||||
|
}
|
||||||
|
return m
|
||||||
|
}
|
||||||
|
|
||||||
|
export const builder = () => _import('@nuxt/builder')
|
||||||
|
export const webpack = () => _import('@nuxt/webpack')
|
||||||
|
export const generator = () => _import('@nuxt/generator')
|
||||||
|
export const core = () => _import('@nuxt/core')
|
||||||
|
Loading…
Reference in New Issue
Block a user