簡體   English   中英

全局安裝節點 package 沒有互聯網服務器錯誤:沒有這樣的文件或目錄

[英]Installing node package globally without internet on server error: No such file or directory

我正在使用 nodejs 項目。 該項目具有 npm 包的本地和全局依賴關系。 我們要部署項目的服務器沒有互聯網連接。 因此,我們正在嘗試在服務器上安裝 npm 軟件包。

對於本地依賴,將本地依賴從本地機器復制到服務器作品。 但是,我們正在努力安裝全局軟件包。

我們正在使用以下全局包:

  1. 松露 v4.1.12。
  2. PM2

要安裝全局包,我們嘗試了以下幾種方法:

將可執行文件從本地機器復制到/user/local/bin
將內容從lib/node_modules/truffle復制到/usr/local/lib/node_modules/truffle

但是,它沒有用。 即使找到了文件cli.bundled.js ,也顯示如下錯誤。

[redhat@redhat8 ~]$ truffle -v
/usr/local/bin/truffle: line 1: ../lib/node_modules/truffle/build/cli.bundled.js: No such file or directory

我認為這是符號鏈接的問題,所以嘗試創建它

ln -s /usr/local/bin/truffle /usr/local/lib/node_modules/truffle/build/cli.bundled.js

但是它仍然顯示相同的錯誤。 有沒有辦法讓它工作?

與其作為全局模塊安裝(這需要您更多地了解目標系統的配置方式),不如將其安裝為對等依賴項。

npm install --save-peer pm2 truffle

這會將可執行文件放在node_modules中。 要調用它們,請確保您位於帶有package.json文件的目錄中。 (這對於啟動腳本和類似的東西來說很重要,當然。)然后您可以使用npx調用可執行文件:

$ npx truffle -v
npx truffle -v   
Truffle v5.3.0 - a development framework for Ethereum

Usage: truffle <command> [options]

Commands:
  build     Execute build pipeline (if configuration present)
  compile   Compile contract source files
  config    Set user-level configuration options
  console   Run a console with contract abstractions and commands available
  create    Helper to create new contracts, migrations and tests
  db        Database interface commands
  debug     Interactively debug any transaction on the blockchain
  deploy    (alias for migrate)
  develop   Open a console with a local development blockchain
  exec      Execute a JS module within this Truffle environment
  help      List all commands or provide information about a specific command
  init      Initialize new and empty Ethereum project
  install   Install a package from the Ethereum Package Registry
  migrate   Run migrations to deploy contracts
  networks  Show addresses for deployed contracts on each network
  obtain    Fetch and cache a specified compiler
  opcode    Print the compiled opcodes for a given contract
  preserve  Save data to decentralized storage platforms like IPFS and Filecoin
  publish   Publish a package to the Ethereum Package Registry
  run       Run a third-party command
  test      Run JavaScript and Solidity tests
  unbox     Download a Truffle Box, a pre-built Truffle project
  version   Show version number and exit
  watch     Watch filesystem for changes and rebuild the project automatically

See more at http://trufflesuite.com/docs
$ 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM