标签: node-modules

为什么当我指示更高版本的 NodeJS 时“npm install”没有失败?

我想在我的 NodeJS 项目中强制执行 NodeJS 和 NPM 的确切版本。这是我的 package.json:

{
  "name": "nodesandbox",
  "version": "0.0.1",
  "dependencies": {
    "less": "*"
  },
  "engines": {
    "node": "0.10.25"
  }
}
Run Code Online (Sandbox Code Playgroud)

当我运行时,nvm ls我得到这个输出:

    v0.2.6
    v0.7.12
    v0.9.6
  v0.10.12
  v0.10.15
  v0.10.21
current:    v0.10.24
Run Code Online (Sandbox Code Playgroud)

当我运行时npm install它工作正常,但我希望它失败。我已按照此链接 [1] 中的说明进行操作,这就是为什么我认为在引擎对象中设置节点版本应该可行,但遗憾的是它不起作用。

[1] http://blog.nodejitsu.com/package-dependencies-done-right/#node-dependency-in-apps

javascript node.js npm node-modules

8
推荐指数
1
解决办法
2328
查看次数

从反应组件调用节点模块

我如何在 React 组件中使用节点模块,例如“lwip”?这是针对电子应用的。

用代码更新问题:

  1. 这是我试图从中调用另一个 .js 文件的 react 组件。

按钮.js

import React from 'react';
import ReactDOM from 'react-dom';
import resize from '../../node-code/process';

class Button extends React.Component{

    mess(){
        console.log('working');
        resize();
    }

    render(){
        return <button id="imgButton" onClick={this.mess.bind(this)}>Upload Image</button>
    }
}

export default Button
Run Code Online (Sandbox Code Playgroud)
  1. 这是我尝试调整图像大小的另一个 javascript 文件。

进程.js

var lwip = require('lwip');

export default function(){
    var lwip = require('lwip');
    lwip.open('../../public/img/portrait.jpg', function(err, image){


    image.batch()
        .scale(0.75)          // scale to 75%
        .rotate(45, 'white')  // rotate 45degs clockwise (white fill)
        .crop(200, 200)       // crop a 200X200 square …
Run Code Online (Sandbox Code Playgroud)

node.js lwip node-modules reactjs electron

8
推荐指数
1
解决办法
4366
查看次数

如何在 npm 包中添加文件夹作为条目?

我正在尝试发布一个 npm 模块。它具有以下文件夹结构。 在此处输入图片说明

在我package.json看来,"main": "./dist/"我理解这种对index.js. 但是在 dist 文件夹中,我有名为string.js, 的单个文件class.js,dom.js我打算将它们导入为, import { isValidZipCode } from '@scope/utils/string';但现在我必须将它们导入为import { isValidZipCode } from '@scope/utils/dist/string';

当我从中导入模块时,有没有办法解析文件夹node_modules?

编辑:主要思想是导入文件,就像import { isValidZipCode } from '@scope/utils/string'我为单个导出保留单个文件一样。

javascript node.js npm node-modules yarnpkg

8
推荐指数
1
解决办法
2756
查看次数

致命错误:使用任何“npm”命令时 JavaScript 堆内存不足

尝试运行任何 npm 命令时出现错误(致命错误:MarkCompactCollector:半空间复制,旧代分配失败 - JavaScript 堆内存不足)。即使运行“npm -v”也会发生错误。

也经历了线程-(npm install - javascript heap out of memory)但这并没有帮助我解决我的问题。

胎儿错误

    FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed 
    - 
    JavaScript heap out of memory
    1: 000000013F56F04A 
       v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+5114
    2: 000000013F54A0C6 node::MakeCallback+4518
    3: 000000013F54AA30 node_module_register+2032
    4: 000000013F7D20EE v8::internal::FatalProcessOutOfMemory+846
    5: 000000013F7D201F v8::internal::FatalProcessOutOfMemory+639


    6: 000000013FCF2BC4 v8::internal::Heap::MaxHeapGrowingFactor+9556

     7: 000000013FCE9C46 v8::internal::ScavengeJob::operator=+24310
     8: 000000013FCE829C v8::internal::ScavengeJob::operator=+17740
     9: 000000013FCEE1B7 v8::internal::Heap::CreateFillerObjectAt+1175
    10: 000000013FB7C5B3 
    v8::internal::interpreter::Interpreter::GetDispatchCounters
    Object+78451
    11: 000000013F4D1132 
        v8::internal::StackGuard::ArchiveSpacePerThread+52082
    12: 000000013F4D17F3 
        v8::internal::StackGuard::ArchiveSpacePerThread+53811
    13: 000000013F5B1474 uv_dlerror+2436
    14: 000000013F5B21D8 uv_run+232

15: 000000013F55128E node::NewContext+1390
16: …
Run Code Online (Sandbox Code Playgroud)

javascript node.js npm node-modules npm-install

8
推荐指数
1
解决办法
1万
查看次数

无法确定“@angular/cli”本地安装的版本已损坏

所以,我在安装 moment 插件后破坏了我的本地安装。这个Momento 插件

安装完成后,当我将命令放入ng serve运行项目时,控制台返回的是:

无法确定“@angular/cli”的版本。这可能意味着您的本地安装已损坏。请重新安装您的软件包。

我遵循了这个:找不到模块“@angular-devkit/build-angular”,但什么也没有。

所以,我试过重新安装 angular,但没有,我试过运行 npm update 但没有……我不知道如何解决这个问题,我需要工作。

另外,尝试通过 git 重新结帐,但没有。

该项目诞生于 Angular 7 和 Material。如何解决这个问题?

npm node-modules angular-cli angular angular7

8
推荐指数
2
解决办法
1万
查看次数

EPERM:不允许操作,mkdir 'C:\Program Files\nodejs\node_modules\.staging

我正在尝试在我的项目上运行 npm install 但它显示 EPERM: operation not allowed, mkdir 'C:\Program Files\nodejs\node_modules.staging

我没有 root 管理权限。我在我的系统中作为本地用户使用,我的系统是 Windows 10

节点 v10.16.3 npm v6.11.3

任何人都可以帮我解决这个问题。我请你们。

3235 error code EPERM
3236 error syscall mkdir
3237 error path C:\Program Files\nodejs\node_modules\.staging
3238 error errno -4048
3239 error Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_modules\.staging'
3239 error  { [Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_modules\.staging']
3239 error   cause:
3239 error    { Error: EPERM: operation not permitted, mkdir 'C:\Program Files\nodejs\node_modules\.staging'
3239 error      errno: -4048,
3239 error      code: …
Run Code Online (Sandbox Code Playgroud)

node.js npm node-modules

8
推荐指数
2
解决办法
2万
查看次数

为什么在创建新的 eslint-plugin 后“vue-cli-service build”失败,并出现错误“TypeError: eslint.CLIEngine is not a constructor”?

为自定义规则创建新的 eslint-plugin 后,vue-cli-service build失败(eslint按预期工作,由 触发时./node_modules/.bin/eslint --ext .js,.vue,.json ./ --max-warnings=0)。

GitHub存储库重现问题

从工作环境开始vue-cli-service build,按照https://blog.webiny.com/create-custom-eslint-rules-in-2-minutes-e3d41cb6a9a0 上的简化说明,也会重现该问题。vue-cli-service build在每一步运行后,它在第 4 步之后开始失败yarn add --dev file:./eslint,并且在所有步骤完成后构建仍然失败。

错误信息:

ERROR  Failed to compile with 32 errors      

Module build failed (from ./node_modules/@vue/cli-plugin-eslint/node_modules/eslint-loader/index.js):
TypeError: eslint.CLIEngine is not a constructor
   at Object.module.exports (MYPATH/node_modules/@vue/cli-plugin-eslint/node_modules/eslint-loader/index.js:223:27)

***repeats 31 more times***

You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ …
Run Code Online (Sandbox Code Playgroud)

node-modules eslint vue.js yarnpkg vue-cli

8
推荐指数
1
解决办法
2021
查看次数

在 NodeJS 中使用绝对路径导入 ES6 模块而不使用 Babel/Webpack

我有一个普通的旧 NodeJS 项目(使用 Typescript),我真的很难找出如何为本地文件执行 ES6 导入,而不必一直执行“../../../foo/bar”。

有很多类似的问题,但似乎都围绕着我没有使用的 babel/Webpack 展开。

如果我执行以下操作:

import foo from `/bar`
Run Code Online (Sandbox Code Playgroud)

它在我 PC 的根文件夹(例如 c:/bar)中查找它并失败。

我曾尝试使用 .env 文件并将 NODE_PATH 设置为各种铰链(“/”、“.”等),但没有运气。我也试过在我的 package.json 中设置“type: 'module'”,我的 tsconfig.json 文件有 {"baseUrl": "."}

所以我想我已经尝试了我能找到的所有答案。我只是在错误的组合中使用它们还是解决方案有所不同?

javascript node.js node-modules typescript es6-modules

8
推荐指数
3
解决办法
3045
查看次数

无法更新节点版本 - 意外令牌

最近为了技术评估将我的节点降级到版本 12,现在想要升级,但似乎出了问题。我尝试了很多大家都建议的事情。

不是一个非常熟练的 mac 用户,所以任何帮助表示赞赏

MacBook-Pro ~ % npm install -g n
ERROR: npm v9.1.2 is known not to run on Node.js v12.22.12. You'll need to
upgrade to a newer Node.js version in order to use this version of npm. This
version of npm supports the following node versions: `^14.17.0 || ^16.13.0 ||
>=18.0.0`. You can find the latest version at https://nodejs.org/.

ERROR:
/usr/local/lib/node_modules/npm/lib/utils/exit-handler.js:22
  const hasLoadedNpm = npm?.config.loaded
                           ^

SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at …
Run Code Online (Sandbox Code Playgroud)

macos npm node-modules

8
推荐指数
1
解决办法
2万
查看次数

8
推荐指数
1
解决办法
6688
查看次数