Giter Club home page Giter Club logo

modules's Introduction

关于必须删除node_modules包在npm i才可以 正常运行的一种论证

三个文件夹介绍

  1. main项目为平时开发的主项目,其中会依赖module1和module2
require('@zwhkk/module1')
  1. module2
    [email protected]中 global.module2 = 'variable module2, v2.0.0' [email protected]中 global.module2 = () => 'function module2, v2.0.1'

  2. module1

require('@zwhkk/module2')

console.log('module1中打印global.module2: ', global.module2)
console.log('module1中打印global.module2(): ', global.module2())

复现步骤

# 查看node_modules中依赖包关系
npm ls

# 进入main项目,
cd main

# 几个月安装了[email protected]
npm i @zwhkk/[email protected] -S

# 现在module2已经升级为2.0.1, 且module1依赖形式为 "@zwhkk/module2": "^2.0.0"
npm i @zwhkk/module1 -S

# 安装结果为下面,
# @zwhkk/[email protected]
# @zwhkk/[email protected]

# 执行文件, 此时global.module2是变量不是函数,所以报错
node index.js

# 删除node_modules和package-lock.json,然后npm i,此时global.module2是函数,正常运行
npm i
# @zwhkk/[email protected]
# @zwhkk/[email protected]

# 执行文件, 此时global.module2是函数,正常运行
node index.js

modules's People

Watchers

wenhao(浩烟) avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.