Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
247 views
in Technique[技术] by (71.8m points)

javascript - for what "../.." used for? I found it today in this line var express = require('../..');

Hey I was trying to understand node-js routes and found this sentence "var express = require('../..');" I don't understand the meaning/usage of '../..' here please can someone explain it to me?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

'../..' is a relative path to index.js file which is situated two folders behind.

Let's say hypothetically your folder structure looks like this -

folder1
  - index.js
  - folder2
      - folder3
          - your-code.js

and your-code.js looks like this,

const express = require('../..');

will mean to import the JS module from 'index.js' file in folder1


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...