Installing node package globally without internet on server error: No such file or directory
Installing node package globally without internet on server error: No such file or directory
我正在使用 nodejs 项目。该项目具有 npm 包的本地和全局依赖性。我们要部署项目的服务器没有互联网连接。所以,我们正在尝试在服务器上安装 npm 包。
对于本地依赖,将本地依赖从本地机器复制到服务器工作。但是,我们正在努力安装全局包。
我们正在使用以下全局包:
- Truffle v4.1.12.
- 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
我认为这是符号问题 link 所以尝试创建它
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
$
我正在使用 nodejs 项目。该项目具有 npm 包的本地和全局依赖性。我们要部署项目的服务器没有互联网连接。所以,我们正在尝试在服务器上安装 npm 包。
对于本地依赖,将本地依赖从本地机器复制到服务器工作。但是,我们正在努力安装全局包。
我们正在使用以下全局包:
- Truffle v4.1.12.
- 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
我认为这是符号问题 link 所以尝试创建它
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
$