作为NPM依赖项安装node 6.10.3

3

我正在使用serverless框架开发项目,并将其部署到AWS Lambda,我希望运行与AWS Lambda上可用的相同版本的node-即node 6.10.3。 将其添加到"engines"中没有任何效果,因此我还将其添加到"dependencies"中,但安装该依赖项始终失败:

> node@6.10.3 preinstall /Users/ssterling3/Documents/2017/IIT/Apps/Student Dashboard/mobile-dashboard/node_modules/node
> node installArchSpecificPackage

npm ERR! code ETARGET
npm ERR! notarget No matching version found for node-darwin-x64@6.10.3
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/ssterling3/.npm/_logs/2017-09-15T20_58_25_281Z-debug.log
module.js:471
    throw err;
    ^

Error: Cannot find module 'node-darwin-x64/package.json'
    at Function.Module._resolveFilename (module.js:469:15)
    at Function.resolve (internal/module.js:27:19)
    at ChildProcess.<anonymous> (/Users/ssterling3/Documents/2017/IIT/Apps/Student Dashboard/mobile-dashboard/node_modules/node-bin-setup/index.js:18:27)
    at emitTwo (events.js:106:13)
    at ChildProcess.emit (events.js:191:7)
    at maybeClose (internal/child_process.js:886:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node@6.10.3 preinstall: `node installArchSpecificPackage`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node@6.10.3 preinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/ssterling3/.npm/_logs/2017-09-15T20_58_25_350Z-debug.log

这似乎是最新日志文件的相关部分:
59 silly preinstall node@6.10.3
60 info lifecycle node@6.10.3~preinstall: node@6.10.3
61 verbose lifecycle node@6.10.3~preinstall: unsafe-perm in lifecycle true
62 verbose lifecycle node@6.10.3~preinstall: PATH: /opt/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/ssterling3/Documents/2017/IIT/Apps/Student Dashboard/mobile-dashboard/node_modules/node/node_modules/.bin:/Users/ssterling3/Documents/2017/IIT/Apps/Student Dashboard/mobile-dashboard/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/MacGPG2/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/usr/local/munki:/Users/ssterling3/bin:/opt/local/bin/:/Users/ssterling3/.npm-global/bin/:/Users/ssterling3/.gem/ruby/2.4.0/bin/
63 verbose lifecycle node@6.10.3~preinstall: CWD: /Users/ssterling3/Documents/2017/IIT/Apps/Student Dashboard/mobile-dashboard/node_modules/node
64 silly lifecycle node@6.10.3~preinstall: Args: [ '-c', 'node installArchSpecificPackage' ]
65 silly lifecycle node@6.10.3~preinstall: Returned: code: 1  signal: null
66 info lifecycle node@6.10.3~preinstall: Failed to exec preinstall script
67 verbose unlock done using /Users/ssterling3/.npm/_locks/staging-9795425667a03fed.lock for /Users/ssterling3/Documents/2017/IIT/Apps/Student Dashboard/mobile-dashboard/node_modules/.staging
68 verbose stack Error: node@6.10.3 preinstall: `node installArchSpecificPackage`
68 verbose stack Exit status 1
68 verbose stack     at EventEmitter.<anonymous> (/opt/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:280:16)
68 verbose stack     at emitTwo (events.js:106:13)
68 verbose stack     at EventEmitter.emit (events.js:191:7)
68 verbose stack     at ChildProcess.<anonymous> (/opt/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
68 verbose stack     at emitTwo (events.js:106:13)
68 verbose stack     at ChildProcess.emit (events.js:191:7)
68 verbose stack     at maybeClose (internal/child_process.js:886:16)
68 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
69 verbose pkgid node@6.10.3
70 verbose cwd /Users/ssterling3/Documents/2017/IIT/Apps/Student Dashboard/mobile-dashboard
71 verbose Darwin 16.7.0
72 verbose argv "/opt/local/bin/node" "/opt/local/bin/npm" "install" "node@6.10.3"
73 verbose node v6.10.3
74 verbose npm  v5.4.0
75 error code ELIFECYCLE
76 error errno 1
77 error node@6.10.3 preinstall: `node installArchSpecificPackage`
77 error Exit status 1
78 error Failed at the node@6.10.3 preinstall script.
78 error This is probably not a problem with npm. There is likely additional logging output above.
79 verbose exit [ 1, true ]

看起来它正在尝试获取包的特定于平台的变体,但服务器上没有。

没有其他依赖项(或devDependencies)受到影响。

这是在macOS Sierra 10.12.6(16G29)上,使用MacPorts 2.4.1、macports nodejs6 @6.10.3_0和macports npm5 @5.4.0_0。

  • npmjs.com 真的没有匹配的版本吗?
  • 它是否可以从其他来源获得?
  • 我能做些什么来帮助npmjs.com使其可用吗?

也许我理解你的问题有误,但如果你只需要安装特定版本的node,你可以使用nvm(https://github.com/creationix/nvm)。不确定npm是否旨在用于每个项目的node版本控制。 - zinfandel
我宁愿不让每个人都开始使用另一个软件包管理器。Node软件包的npmjs页面给我的印象是,我正在尝试做的正是它的预期用途:https://www.npmjs.com/package/node - ShadSterling
如果你正在运行 macports nodejs6 @6.10.3_0,那么你已经在运行正确的版本了。 - Noel Llevares
这只是我的个人想法,为什么要强制每个人都使用macports并按照过时的安装程序进行安装呢?即使其他人不重要,每次我运行“port upgrade outdated”时,它都会升级到当前版本,而回滚则是一件很麻烦的事情,我宁愿不要一直处理这个问题。 - ShadSterling
1个回答

2

在联系维护者后,现在存在npm包node-darwin-x64@6.10.3,这解决了问题。

(Lambda现在也支持node 8.10.0,并且相应的node-darwin-x64@8.10.0也存在。)


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接