@0ti.me/en-path 中文文档教程
en-path
srelative
// This fails because the path ends up being 'module.js' which require will interpret as an npm dependency instead of a file path
const path = require('path');
const module = require(path.relative(__dirname, 'module.js'));
一个增强的路径模块,它添加了一个相对函数,确保所有路径都可以被要求使用。 你可以在这里看到它的实际效果:
const enPath = require('en-path');
const module = require(enPath.srelative(__dirname, 'module.js'));
en-path
srelative
// This fails because the path ends up being 'module.js' which require will interpret as an npm dependency instead of a file path
const path = require('path');
const module = require(path.relative(__dirname, 'module.js'));
An enhanced path module that adds a srelative function that ensures all paths are usable by require. You can see it in action here:
const enPath = require('en-path');
const module = require(enPath.srelative(__dirname, 'module.js'));