node.js - 在 Ubuntu 18.04 上安装 node-sass 失败
问题描述
我有一个简单的 next.js 项目,我是按照他们的教程创建的。它在我的 Windows 开发机器上构建和运行良好。
我想在 Ubuntu 18.04.02 LTS 上部署它,但是当我克隆 git 项目并运行它时npm install
,它无法安装 node-sass,并出现以下错误消息:
> node-sass@4.12.0 install /var/www/example.com/beta/node_modules/node-sass
> node scripts/install.js
internal/modules/cjs/loader.js:584
throw err;
^
Error: Cannot find module '/var/www/example.com/beta/node_modules/node-sass/scripts/install.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15)
at Function.Module._load (internal/modules/cjs/loader.js:508:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:754:12)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.12.0 install: `node scripts/install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass@4.12.0 install 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: ...
这是日志文件的要点。请参阅错误的最后几行(我已经包含了整个文件,以防有其他有用的信息)。
我的 NodeJS 版本是 10.15.3,我的 NPM 版本是 6.4.1。我不确定如何在 Ubuntu 上运行 next.js 项目。
解决方案
显然,我需要用--unsafe-perms
标志安装它:
npm install --unsafe-perms
没有解释为什么它需要这个,而且unsafe
很多人不推荐这个词。
此外,文件夹权限需要使脚本可以创建文件夹。我必须创建一个文件夹me
,在那里克隆 repo,运行npm install --unsafe-perms
,然后将权限设置为生产 Web 服务器。
参考请看这里。
推荐阅读
- html - 嵌套标签语法高亮警告
- paypal - Google Pay PayPal 是否已弃用?
- typescript - 表达式预期 & ':' 预期
- android - 在应用启动时更改全屏背景(Android 5.11 使用自定义主题)
- jmeter - Jmeter 无法加载类 com.azure.messaging.eventhubs.EventDataBatch
- python - Windows 10 M2Crypto“ImportError:DLL 加载失败:找不到指定的过程。”
- entity-framework-core - 使用 EF Core 3.1 在 Azure 函数中迁移 SQL 数据库时缺少 System.ComponentModel.Annotations
- r - 从具有多个模型的 lm lapply 循环中提取最终 p 值统计量
- html - html 中的滞后 gif... 有时
- javascript - WKWebView 的 evaluateJavaScript 的返回类型